JavaScript - Blackjack Game In Js, How Do I Update Information On The Page After It Has Loaded?
Hi, ive been asked to make a blackjack game in javascript but I have a little bit of a problem. When the page loads, it deals cards to the player and the dealer, showing which cards have been dealt and the current scores. When I press the HIT button, i need to add another card to the array player_hand_img, and the value of this card to player_hand. I have successfully created this code, but my question is, how do I update the information (the score and the cards) on the screen after it has loaded? Can you do this in JavaScript or do I need another language?
Thanks very much in advance! Similar TutorialsOk basically i am making a blackjack game and so far i have a random generator for my cards, once i press deal 4 cards are dealt at random, but when i try to insert a new button for the player to press for another card "hit", the card comes down and is not random at all. I could really do with this help. Thank you. Code: <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> var deck=new Array; var hand=new Array(53); var hcrd=new Array(53); var hsut=new Array(53); var isPlaying=-1; var betn=1; var dpos=0; var crdts; var ncard=0; /* ----------------------------------------------------------------------------------------- */ function initdeck(){ crd=0; for(i=0;i<4;i++){ if(i==0){st="club";} else if(i==1){st="heart";} else if(i==2){st="diamond";}else{st="spade";} for(c=1;c<14;c++){ if(c==1){num="ace";}else if(c==11){num="jack";} else if(c==12){num="queen";}else if(c==13){num="king";}else{num=c;} deck[crd++]=st+"|"+num; } //for c } //for i } /* ----------------------------------------------------------------------------------------- */ function showcard(cnum) { p = hand[cnum].indexOf("|"); s = hand[cnum].substring(0,p); c = hand[cnum].substring(p+1,hand[cnum].length); if(cnum==0){document.images.card1.src="cards/"+s+c+".jpg";} else if(cnum==1){document.images.card2.src="cards/"+s+c+".jpg";} else if(cnum==2){document.images.card3.src="cards/"+s+c+".jpg";} else if(cnum==3){document.images.card4.src="cards/"+s+c+".jpg";} else{document.images.card11.src="cards/"+s+c+".jpg";} } function hit(ncard) { p = hand[ncard].indexOf("|"); s = hand[ncard].substring(0,p); c = hand[ncard].substring(p+1,hand[ncard].length); if(ncard==4){document.images.card5.src="cards/"+s+c+".jpg";} else if(ncard==5){document.images.card6.src="cards/"+s+c+".jpg";} else if(ncard==6){document.images.card7.src="cards/"+s+c+".jpg";} } function stand() { document.images.card8.src="cards/"+s+c+".jpg"; } function deal() { if(isPlaying < 0) { // new game dpos = 0; isPlaying=1; for(i=0;i<500;i++) { //shuffle the cards(mix up the deck) tmp = Math.round(Math.random()*51); tmp2= Math.round(Math.random()*51); stmp = deck[tmp]; deck[tmp] = deck[tmp2]; deck[tmp2] = stmp; } for(i=0;i<53;i++) { hand[i]=deck[dpos++];showcard(i); hand[i]=deck[dpos++];hit(i); } } } function quit(){window.close();} /* ----------------------------------------------------------------------------------------- */ initdeck(); // End --> </script> </HEAD> <BODY> <table> <tr><form name="drwcrd"> <td width=590></td> <td><b>Computer</b></td> </tr><tr></form> <table> <tr><form name="drwcrd"> <td width=500></td> <td width=30 align=center><img name="card1" src="cards/cardback.jpg"></td> <td width=30 align=center><img name="card3" src="cards/cardback.jpg"></td> <td width=30 align=center><img name="card8" src=""></td> <td width=30 align=center><img name="card9" src=""></td> <td width=30 align=center><img name="card10" src=""></td> <table> <tr><form name="drwcrd"> <td width=590></td> <td><b>Player</b></td> </tr><tr></form> <table> <tr><form name="drwcrd"> <td width=500></td> <td width=30 align=center><img name="card2" src="cards/cardback.jpg"</td> <td width=30 align=center><img name="card4" src="cards/cardback.jpg"</td> <td width=30 align=center><img name="card5" src=""</td> <td width=30 align=center><img name="card6" src=""</td> <td width=30 align=center><img name="card7" src=""</td> </tr><tr></form> <table> <tr><td><input type="button" value ="DEAL Cards" onClick="javascript:deal();"></td> <td><input type="button" value ="Hit" onClick="javascript:hit();"></td> <td><input type="button" value ="Stand" onClick="javascript:stand();"></td> </body> </html> if anyone has any help id be grateful or if anyone has any ideas on how to approach this differently. thanks in advance please excuse the code its a little messy atm. sorry Hey guys I need help on making the images on this game show up. Im not sure how to get the card images to load when hitting the deal button. Code: <html> <head> <title> Blackjack </title> <script LANGUAGE="JavaScript1.1"> var dealer_hand = new Array(); var player_hand = new Array(); var game_over = false; function Card(num,suit) { this.num = num; this.suit = suit; this.fname = fname; } function fname() { return this.num + this.suit + ".gif"; } function Deck() { this.cards = new Array(52); this.next_card = 0; // fill the deck (in order, for now) for (i=1; i<14; i++) { this.cards[i-1] = new Card(i,"c"); this.cards[i+12] = new Card(i,"h"); this.cards[i+25] = new Card(i,"s"); this.cards[i+38] = new Card(i,"d"); } this.shuffle = shuffle; this.dealCard = dealCard; } function shuffle() { for (i=1; i<1000; i++) { // switch two randomly selected cards card1 = Math.floor( 52*Math.random() ); card2 = Math.floor( 52*Math.random() ); temp = this.cards[card2]; this.cards[card2] = this.cards[card1]; this.cards[card1] = temp; } this.next_card = 0; } function dealCard() { return this.cards[ this.next_card++ ]; } var deck = new Deck(); deck.shuffle(); function newGame() { if ( deck.next_card > 39 ) { deck.shuffle(); } dealer_hand = new Array(); player_hand = new Array(); dealer_hand[ 0 ] = deck.dealCard(); // This is the hole card. document.images[0].src = "http://www.litchzen.com/cardback.PNG"; // The hole card is not shown dealer_hand[ 1 ] = deck.dealCard(); document.images[ 1 ].src = dealer_hand[ 1 ].fname(); for ( i=2; i<6; i++) { document.images[i].src = "http://www.litchzen.com/cardback.PNG"; } num = i + 1; player_hand[ 0 ] = deck.dealCard(); document.images[ 6 ].src = player_hand[ 0 ].fname(); player_hand[ 1 ] = deck.dealCard(); document.images[ 7 ].src = player_hand[ 1 ].fname(); for (i=8; i<12; i++) { document.images[i].src = "http://www.litchzen.com/cardback.PNG"; } window.status = ""; document.form1.dealer.value = ""; document.form1.result.value = ""; document.form1.player.value = score( player_hand ); game_over = false; } // end function newGame() function hit() { var total = 0; var new_card = 0; // index for the new card position if ( game_over ) { window.status = "Game over. Click the Deal button to start a new hand." } else { new_card = player_hand.length; player_hand[ new_card ] = deck.dealCard(); document.images[ new_card + 6 ].src = player_hand[ new_card ].fname(); total = score( player_hand ); if ( total > 21 ) { // Busted, game over. document.form1.player.value = total + " busted"; document.images[ 0 ].src = dealer_hand[ 0 ].fname(); document.form1.dealer.value = score( dealer_hand ); winner(); game_over = true; } else { document.form1.player.value = total; } } } // end function hit() function stand() { var total = 0; var new_card = 0; if ( game_over ) { window.status = "Game over. Click the Deal button to start a new hand." } else { document.images[ 0 ].src = dealer_hand[ 0 ].fname(); while ( score( dealer_hand ) < 17 ) { new_card = dealer_hand.length; dealer_hand[ new_card ] = deck.dealCard(); document.images[ new_card ].src = dealer_hand[ new_card ].fname(); } total = score( dealer_hand ); if ( total > 21 ) { // Busted document.form1.dealer.value = total + " busted"; } else { document.form1.dealer.value = total; } } winner(); game_over = true; // The game ends after the player stands. } // end function stand() function score(hand) { var total = 0; var soft = 0; // This variable counts the number of aces in the hand. var pips = 0; // The trump pictures on a card used to be called pips. for ( i=0; i<hand.length; i++ ) { pips = hand[i].num; if ( pips == 1 ) { soft = soft + 1; total = total + 11; } else { if ( pips == 11 || pips == 12 || pips == 13 ) { total = total + 10; } else { total = total + pips; } } } while ( soft > 0 && total > 21 ) { // Count the aces as 1 instead total = total - 10; // of 11 if the total is over 21 soft = soft - 1; } return total; } // end function score function winner() { var player_total = score( player_hand ); var dealer_total = score( dealer_hand ); if ( player_total > 21 ) { // Busted document.form1.result.value = "Dealer wins"; } else { if ( dealer_total > 21 ) { // Busted document.form1.result.value = "Player wins"; } else { if ( player_total == dealer_total ) { document.form1.result.value = "Tie game"; } else { if ( player_total > dealer_total ) { document.form1.result.value = "Player wins"; } else { document.form1.result.value = "Dealer wins"; } } } } } </script> </head> <body> <h1>Blackjack Javascript Example</h1> <hr> <form NAME="form1"> <table> <tr> <td> <B>Dealer: </B> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> </td> </tr> <tr> <td> <B>Player: <B> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> <td> <img border=0 src="http://www.litchzen.com/cardback.PNG" height=125 width=95> </tr> <tr> <td> <B>Dealer Sco </B><BR> <input TYPE="TEXT" SIZE=12 NAME="Dealer" VALUE="0"></td> <td> <B>Player Sco </B><BR> <input TYPE="TEXT" SIZE=12 NAME="You" VALUE="0"> <td> <input TYPE="BUTTON" VALUE=" Stay " onClick="stand();"> <td> <input TYPE="BUTTON" VALUE=" Hit " onClick="hit();"> <td> <a href="#" onClick="newGame();" onMouseOver = "window.status = 'Deal a new hand.'; return true; " onMouseOut = "window.status = '';"> <img border=0 src="http://us.cdn3.123rf.com/168nwm/fuzzbones/fuzzbones1105/fuzzbones110500782/9628185-deal-word-in-male-hand.jpg" height=50 width=106></a> <td> <B>Game Result:</B><BR> <input TYPE="TEXT" SIZE=10 NAME="result" VALUE=""</td> </tr> </table> </form> <P>Click the Deal button to start a new game.<BR> Click the Hit button to get another card.<BR> Click the Stay button to end your turn. Try and get as close to 21 as possible to win. Good luck!</P> </body> </html> i have an iframe on my webpage and i am loading appropriate page in it by clicking appropriate button but when user logs out and at that time some page is opened in iframe corresponding to the login pages(like "edit profile") of user then at that moment i want to know that what page is loaded in iframe so that i close it(if it corresponds to pages of login like "edit profile") as user logs out and if it does not correspond to login pages then it remains as it is.For doing that i must know that what page is loaded in iframe and compare it in " if(condition){statement} in logout function" with the logion pages so that i know that if any of them is loaded in iframe and if loaded then close it.Can you help me with that by giving exact code example. Im running js to do some color coding in a table, i tried adding the onload but its not working, can someone take a look ? I need this to run when the entire page is fully loaded and not before. THE FUNCTION Code: var table1_column_settings = [ [32,40], // ito score - First column values more than 5 will be red, 2-5 will be yellow, less than 2 will be green [11,12], // schedule [14,15], // cost [11,12], // execution [9,10], // commercial [41,50] // total ]; // Loop through all cells in a table, coloring each one according to column-specific thresholds function color_cells(table, column_settings) { // How many rows are in the table? var num_rows = table.rows.length; // Loop through all rows. for (var r = 0; r < num_rows; r++) { // Get a reference to the current row. var this_row = table.rows[r]; // How many cells are in this row? var num_cells = this_row.cells.length; // Loop through all cells in this row. for (var c = 0; c < num_cells; c++) { // Get a reference to the cell. var this_cell = this_row.cells[c]; // Get the numerical value of the first (and only) node inside the cell. var cell_value = parseFloat(this_cell.firstChild.nodeValue); // If it's a number (literally if it's not not not-a-number) if (!isNaN(cell_value)) { // Apply the color according to the thresholds for this column number (c). if (cell_value > column_settings[c][1]) this_cell.style.backgroundColor= "red"; else if (cell_value > column_settings[c][0]) this_cell.style.backgroundColor= "yellow"; else this_cell.style.backgroundColor = "green"; } } } } EXECUTE THE FUNCTION Code: </TBODY> </table> <script> color_cells(document.getElementById("table1"), table1_column_settings);</script> //I TRIED LIKE THIS <script> window.onload=color_cells(document.getElementById("table1"), table1_column_settings);</script> AND IT DIDNT WORK Hi all, I am facing problem in preventing my web page being loaded into an iFrame. I search in internet and found this solution : if (self == top) document.documentElement.style.display = 'block'; else top.location = self.location; The above java script code is simple redirecting me to the home page of my web site. But I donot want that kind of solution. When anybody tried to access my web page through iFrame, it should show an error message like "The content of the web site cannot be loaded into an IFrame". This message should be displayed inside the iFrame. For example, if we tried to access "google.com" site in an iframe, the website should not allow the iframe object to load into it, insted it will display an error message along with a provision to open webiste with an external link with it. Any help? thanks, -Sanath The project I am working on involves a flash piece that communicates with a iframe. Currently the flash piece just calls on javascript functions. I want the buttons in the flash piece to be able to change the src of the iframe. PHP Code: <script type="text/javascript"> document.getElementById('video').setAttribute('src',address2); function closeVideo() { document.getElementById('video').style.height='0px'; return false; document.getElementById('video').setAttribute('src', address2); } function openVideo() { document.getElementById('video').style.height='391px'; return false; document.getElementById('video').setAttribute('src', address); } </script> So the way the code works now is when the page loads it sets the iframe with the id of 'video' to the variable address2 which it pulls from an XML file. In the flash piece when a button is hit, it calls openVideo() which "opens" the iframe and I want it to change the contents to address. This does not work though. It opens the frame but will not change the src. I've tried a bunch of different things now such as make the flash target the iframe using navigateToURL(request1, 'video'); but in Firefox and IE is opens it stills as if I had _blank in there. It does strangely work in Safari. Any ideas how to get this to work? I'm new to javascript so it could be something basic I'm overlooking My source : Code: <html> <head> <title></title> <script type="text/javascript"> function runcode(cwin) { cwin.location.replace("javascript:alert("Loaded complete")"); } function newtab() { win=window.open("http://www.google.com"); setTimeout("runcode(win)",5000); setTiemout("win.close()",7000); } </script> </head> <body> <input type="button" value="Click to open newtab" onclick="newtab()" /> </body> </html> I want after newtab is opened 5s, alert window will be opened with message:"Loaded complete". Then 2s it is closed. But it isn't what I expect. Please fix it for me. Thanks in advance! hi, on my page: here the logos are greyscale but when the page is loading they flash up in colour?! could this be avoided and hidden? here is my Javascript o apply greyscale to my logos Code: $(window).load(function(){ // On window load. This waits until images have loaded which is essential // Fade in images so there isn't a color "pop" document load and then on window load $("#our-work img").animate({opacity:1},500); // clone image $('#our-work img').each(function(){ var el = $(this); el.css({"position":"absolute"}).wrap("<div class='img_wrapper' style='display: inline-block'>").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"998","opacity":"0","margin-left":"64px;"}).insertBefore(el).queue(function(){ var el = $(this); el.parent().css({"width":this.width,"height":this.height}); el.dequeue(); }); this.src = grayscale(this.src); }); // Fade image $('#our-work img').mouseover(function(){ $(this).parent().find('img:first').stop().animate({opacity:1}, 1000); }) $('.img_grayscale').mouseout(function(){ $(this).stop().animate({opacity:0}, 1000); }); }); // Grayscale w canvas method function grayscale(src){ var canvas = document.createElement('canvas'); var ctx = canvas.getContext('2d'); var imgObj = new Image(); imgObj.src = src; canvas.width = imgObj.width; canvas.height = imgObj.height; ctx.drawImage(imgObj, 0, 0); var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height); for(var y = 0; y < imgPixels.height; y++){ for(var x = 0; x < imgPixels.width; x++){ var i = (y * 4) * imgPixels.width + x * 4; var avg = (imgPixels.data[i] + imgPixels.data[i + 1] + imgPixels.data[i + 2]) / 3; imgPixels.data[i] = avg; imgPixels.data[i + 1] = avg; imgPixels.data[i + 2] = avg; } } ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height); return canvas.toDataURL(); } Im very new to java scripting so any help would be truly appreciated. I have a single web page that loads several iframes. One of the iframe pages has to be logged in first. I have that taken care of but once the page is loaded I need to change the source to a link with in the page. My guess is I need something to execute the code like a onload or something. This is what Ive been trying to get to work but like I said a newb! The iframe in question is named "cad" the initial source once loaded is 'https://urlname.com/mainmenu.asp' the source I need to change to is 'https://urlname.com/UnitStatusF.asp?agency_id=28' [CODE] function ChangesSrc() { var iframeid = document.getElementById(cad); var unitstatus = 'https://urlname.com/UnitStatusF.asp?agency_id=28' if (iframeid.src = 'https://urlname.com/mainmenu.asp') iframeid.src = unitstaus; return false; } [[CODE] Hi, I have a site that runs a javascript slideshow automatically when a user visits it. It is designed in such a way that I cannot pre-load individual images for aesthetic reasons. (Also the whole concept makes my brain hurt.) I therefore need 1 of 2 things: 1. A preloader that doesn't show the page or start the slideshow until all the images are loaded. or 2. I could start with the slideshow paused, and when the page is fully loaded, the play command (currently attached to a 'play' button) is 'sent'. (I'm not techy, so this is the best I can do as explanation.) The latter would probably be more elegant, especially if ultimately I could hide the controls for the slideshow with a loading bar until all the html is loaded, and then show them when the slideshow starts. I'm sorry if this is a really basic question. I tried searching the site but couldn't find anything. If you do feel like answering, can you imagine that you are speaking to a 5 year old. Then dumb it down a bit. I need all the explanation and clarity I can get! Thanks! I am having problems calling a JS function from asp.net code behind button click after some code is ran. The first time the button is clicked and it calls the JSfunction the readyState = loading and it cannot find the element. The second time the button is clicked the readystate is complete and it finds the element. Anybody have any suggestions? Here is the code behind ClientScript.RegisterStartupScript(Me.GetType(), "CC", "<SCRIPT language='javascript'>parent.abc('button1')</SCRIPT>") and javascript function abc(src) { if (document.readyState == 'loading') { alert(document.readyState); } else { document.getElementById(src).click(); } } I doubt this is possible, but I have no idea what actually happens when a page loads, so I thought I would give it a shot... if a js file that is loaded externally has parameters, is it possible to turn those parameters into variables, giving the user the option to select the variable's value after the page has loaded? maybe a concrete example would be better... in google maps, the api is loaded like this: Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> but if you wanted to specify that you want the api to function in Spanish, you load it like this: Code: <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=es"></script> and that language=es is the one that I want to change. But I can't seem to make it into a variable on page load, like this: Code: <script type="text/javascript"> var lang="es"; </script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=lang"></script> much less make it changeable once the page has loaded. I have a feeling that this is a really dumb question, but can it be done without reloading the entire page? I have a form with three fields. When the user changes the value of field1, the form displays either field2 or field3. This works fine for NEW records. However, I'm running into a problem when trying to EDIT an existing record. When the form is loaded, I need to test the value of field1 and display either field2 or field3. I've tried using the form onload event, but do not know how to access the value of field1. I'm using Javascript and div tags. This is what I have so far. <script type="text/javascript"> function hide(obj) obj1 = document.getElementById(obj); obj1.style.display = 'none'; } function show(obj) { obj1 = document.getElementById(obj); obj1.style.display = 'block'; } function show_other(optionValue) { if(optionValue=='C') { show('divClass');} else{hide('divClass'); } if(optionValue=='W') { show('divWorkshop');} else{hide('divWorkshop'); } } </script> /* Field1 - is a drop down list */ <select name="ClassType" size="1" onchange="show_other(this.value)"> ... </select> /* Field2 */ <div id="divClass"> ... </div> /* Field 3 */ <div id="divWorkshop"> ... </div> Appreciate any assistance. Thanks Peter Can a random page be loaded without a prior visit to a site? I have a list of 15 people with a photo and contact information in a table with 3 columns and 5 rows. The issue is that the people near the bottom want a chance to be at the top the first time the page is viewed. It is unlikely that a second visit would happen. Is this possible to load a random page for a site without it being viewed or logged into before, therefore no cookies will be used. My knowledge of Java script code is limited so any help would be great. Thanks Motty I would like to create a Blackjack style game for one of my high school programming classes. I can generate 3 different random numbers and use these random numbers to display an image with that number on it. How do I add the 3 separately generated numbers together to show the total?? Here is my code so far. Specifically I would like to add the myNumber1(), myNumber2() and myNumber3() results together. <html> <head> <title>Play 21</title> <script language="javascript"> function myNumber1(){ var rand_no = Math.random(); var myTotal; var ComputerTotal; rand_no = 5 * rand_no + 1; rand_no = Math.floor(rand_no); document.pic1.src = rand_no + ".gif" myNumber2(); myNumber3(); myNumber1D(); myNumber2D(); myNumber3D(); } </script> <script language="javascript"> function myNumber2(){ var rand_no2 = Math.random(); rand_no2 = 5 * rand_no2 + 1; rand_no2 = Math.floor(rand_no2); document.pic2.src = rand_no2 + ".gif" } </script> <script language="javascript"> function myNumber3(){ var rand_no3 = Math.random(); rand_no3 = 5 * rand_no3 + 1; rand_no3 = Math.floor(rand_no3); document.pic3.src = rand_no3 + ".gif" } </script> <script language="javascript"> function myNumber1D(){ var rand_no1D = Math.random(); rand_no1D = 5 * rand_no1D + 1; rand_no1D = Math.floor(rand_no1D); document.pic1D.src = rand_no1D + "D.gif" } </script> <script language="javascript"> function myNumber2D(){ var rand_no2D = Math.random(); rand_no2D = 5 * rand_no2D + 1; rand_no2D = Math.floor(rand_no2D); document.pic2D.src = rand_no2D + "D.gif" } </script> <script language="javascript"> function myNumber3D(){ var rand_no3D = Math.random(); rand_no3D = 5 * rand_no3D + 1; rand_no3D = Math.floor(rand_no3D); document.pic3D.src = rand_no3D + "D.gif" } </script> </head> <body> <table width="94%" border="1"> <tr> <td width="39%"><div align="center">First Number <img src ="1.gif" name="pic1" id=1/> </div></td> <td width="32%"><div align="center">Second Number <img src ="2.gif" name=pic2 id=2/></div></td> <td width="14%"><div align="center">Third Number <img src ="3.gif" name=pic3 id=3/> </div></td> <td width="15%"> </td> </tr> <tr> <td width="39%"><div align="center">First Number <img src ="1D.gif" name="pic1D" id=1/> </div></td> <td width="32%"><div align="center">Second Number <img src ="2D.gif" name=pic2D id=2/></div></td> <td width="14%"><div align="center">Third Number <img src ="3D.gif" name=pic3D id=3/> </div></td> <td width="15%"> </td> </tr> </tr> <tr> <td> </td> <td> </td> <td colspan="2"> </td> </tr> <tr> <td colspan="4"><div align="center"> <input type="submit" name="Deal_Cards" id="Deal_Cards" value="Deal Cards" onClick="myNumber1()" /> </div></td> </tr> </table> </body> </html> jchudson jchudson@mts.net Hi, I am not able to submit the page details in IE 6 since am getting Javascript error: "unknown name" while submitting the page. If i press submit button for second time getting javascript error "Permission Denied". I tried to submit the details in IE 7 aswell the same error occurs. But i tried to submit the page in FireFox, its worked great... submitted without any error and the details saved in the database. I dont understand why the details are not submitted through IE6. Please assist on this. rgds, Ganny. right now i have a webpage that has a <div> with an id of "content". in that div I have a list of anchors. each list item displays data that is pulled from a mysql database. currently I have it set so that when the user clicks an anchor, a URL parameter is passed, which lets the next page populate from the database. however, i really need to make it so that everything stays on the same page; everything happens within the "content" div. how do i do this without passing a url parameter though? so far i've written down: 1. click link 2. call function to empty #content div 3. load in fragment of next page into #content div 4. ??? populate fragment with database info, the row chosen by what link was clicked ??? i'm using jquery and php. so far i've figured out: Code: $('.linkClass').bind('click',callNextPage()); //step 1 function callNextPage(){ $('#content').empty(); //step 2 $('#content').load(nextPage.php #fragmentId); //step3 //step 4 ?? pass in url parameter? or store a GET variable based on which link was clicked? return false; } any ideas? Hi, I have this PHP code that shows the amount of minutes and seconds to a certain date. Somehow I want to update this code every second so that it looks like it's counting down. Anyone who has any good pointers how to do this? Thank you in advance. I am using the following code to show visitors when my page was updated last. It seems really cumbersome for what it does, too. Right now, it reads: Last updated on Monday, December 19, 2011 I wanted to add code to it so that it reads the hours and is in this format: Last updated on Monday, December 19, 2011 at 8:44am How can I add the "at hh:mm am/pm" part? Or is there easier code that will do this? Thank you in advance. Code: function getLongDateString() {month = new Array("January","February","March","April","May","June","July","August","September","October","November","December"); dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); dayOfWeek = this.getDay(); day = dayNames[dayOfWeek]; dateOfMonth = this.getDate(); monthNo = this.getMonth(); month = month[monthNo]; year = this.getYear(); if (year < 2000) year = year + 1900; dateStr = day+", "+month+" "+dateOfMonth+", "+year; return dateStr; } //register the method in the class Date Date.prototype.getLongDateString=getLongDateString; function DocDate() { //return the document modification date (excl.time) //as a string DateTimeStr = document.lastModified; secOffset = Date.parse(DateTimeStr); if (secOffset == 0 || secOffset == null) //Opera3.2 dateStr = "Unknown"; else { aDate = new Date(); aDate.setTime(secOffset); //use method defined above datestr = aDate.getLongDateString(); } return dateStr; } document.write("<left> Last updated on "); document.writeln(DocDate(),"</left>"); Ok so i want to work on an EASY basic game. As simple as Guess what number... But there are some twist... Ok So here is my example... (HTML, i know this.)I'm Guessing a number 1-99. What is it? (java) Lets say its 66 and they guess 53, have the text rusult be in a pop up window be: Too low! (java) Lets say they guess 78, have the text rusult be in a pop up window be: Too high! (java) Lets say they guess 100+, have the text rusult be in a pop up window be: Out of range! (java)But lets say they guess 66, have a text result be in a pop up window be: You've won! (java) I want a text field where you can enter your answer, and it will do the actions above. Can anyone code this? Thanks for reading! |