JavaScript - Help, Word Guess Game Looping Problems
import java.util.Scanner;
import java.util.Arrays; /*********************************************************** * WordGuess game is a Hangman like game for two (or more) * players. This is a two player version *The game of Hangman involves one player making a word and a second * player guessing the word by guessing each letter in turn. If the guessing *player cannot get it in 6 (or so depending on the version) tries, the other *player wins. If the guesser gets it in the requisite number of tries, then the *guesser wins. This is a variant of the Hangman game involving two players *guessing against each other. * * * @author JavaFish * @I can't seem to get my loop working....it's not behaving like i want it to. ***********************************************************/ public class WordGuess { private Scanner kb; // use for all keyboard entry private Player player1; // first player private Player player2; // second player private WordBank wordList; // the dictionary to use /* alternate instance variable for the players deactivate the individual players if you choose to use this version. */ // private Player[] players; /********************************************************* * Explicit value constructor that builds a random dictioinary * * @param player1 The name of player1 * @param player2 The name of player2 ********************************************************/ public WordGuess(String player1, String player2) { wordList = new WordBank(); wordList.getWord(); this.player1 = new Player(player1); this.player2 = new Player(player2); } /********************************************************* * Explicit value constructor that builds a seeded dictioinary * * @param player1 The name of player1 * @param player2 The name of player2 * @param seed The seed to pass to WordBank constructor ********************************************************/ public WordGuess(String player1, String player2, long seed) { wordList = new WordBank(); wordList.getWord(); this.player1 = new Player(player1); this.player2 = new Player(player2); } /********************************************************* * play game plays the game until one player reaches 10 wins *********************************************************/ public void playGame() { boolean loopControl; boolean loopControlOne; boolean loopControlTwo; boolean playerTurn; boolean startOver; String playerInput; char playerCheck; String checkProgress; String checkGuess; String word; char[] dashes; char[] wordLetters; char[] lettersGuessed; kb = new Scanner(System.in); startOver = true; loopControl = true; playerTurn = true; System.out.printf("Welcome to Word Guess %s and %s\n\n", player1.getName(), player2.getName()); if (loopControl) { startOver = true; word = wordList.getWord(); dashes = new char[word.length()]; wordLetters = new char[word.length()]; lettersGuessed = new char[6]; for(int i = 0; i < word.length(); i++) { dashes[i] = ('-'); wordLetters[i] = word.charAt(i); } System.out.print('-'); if(startOver) { checkGuess = new String(lettersGuessed); checkProgress = new String(dashes); loopControlOne = true; loopControlTwo = true; if(playerTurn) { loopControlOne = false; } if (loopControlOne) checkGuess = new String(lettersGuessed); checkProgress = new String(dashes); playerTurn = true; { for(int i = 0; i < word.length(); i++) { System.out.print(dashes[i]); } System.out.print("\nUsed letters: "); for(int i = 0; i < 6; i++) { if(lettersGuessed[i] != 0) { System.out.print(lettersGuessed[i] + " "); } } System.out.printf("\n%s, guess a letter. ", player1.getName()); // Gets the players input and assigns it to variable playerInput playerInput = kb.nextLine(); playerCheck = playerInput.charAt(0); playerInput = new String("" + playerCheck); System.out.println(); for(int i = 0; i < word.length(); i++) { if(playerCheck == wordLetters[i]) { dashes[i] = playerCheck; } } if(checkGuess.contains(playerInput)) { System.out.printf("%s is already guessed. %s, you lose your turn.\n", playerInput, player1.getName()); loopControlOne = false; } else if(word.contains(playerInput)) { for(int i = 0; i < word.length(); i++) { if(wordLetters[i] == playerCheck) { dashes[i] = playerCheck; } } if(checkProgress.contains("-")) { System.out.printf("Correct: %s go again.\n", player1.getName()); for(int i = 0; i < 6; i++) { if(lettersGuessed[i] != 0) { lettersGuessed[i] = playerCheck; i = 6; } Arrays.sort(lettersGuessed); } } else { System.out.printf("Correct. %s you win a point!\n", player1.getName()); System.out.println(word); player1.iWon(); System.out.printf("%s: %d\t%s: %d\n\n", player1.getName(), player1.getScore(), player2.getName(), player2.getScore()); startOver = false; if(player2.getScore() == 5 || player1.getScore() == 5) { System.out.print("Game over. %s wins!\n"); loopControl = false; loopControlTwo = false; } // Set up new loop that clears everything. } } else { System.out.printf("Incorrect. %s, you lose your turn.\n", player1.getName()); loopControlOne = false; for(int i = 0; i < 6; i++) { if(lettersGuessed[i] == 0) { lettersGuessed[i] = playerCheck; i = 6; } Arrays.sort(lettersGuessed); } } } if (loopControlTwo) { checkGuess = new String(lettersGuessed); checkProgress = new String(dashes); playerTurn = true; for(int i = 0; i < word.length(); i++) { System.out.print(dashes[i]); } System.out.print("\nUsed letters: "); for(int i = 0; i < 6; i++) { System.out.print(lettersGuessed[i] + " "); } System.out.printf("%s, guess a letter. ", player2.getName()); // Gets the players input and assigns it to variable playerInput playerInput = kb.nextLine(); playerCheck = playerInput.charAt(0); playerInput = new String("" + playerCheck); for(int i = 0; i < word.length(); i++) { if(playerCheck == wordLetters[i]) { dashes[i] = playerCheck; } } if(checkGuess.contains(playerInput)) { System.out.printf("%s is already guessed. %s, you lose your turn.\n", playerInput, player1.getName()); loopControlTwo = false; } else if(word.contains(playerInput) && checkProgress.contains("-")) { { System.out.printf("Correct: %s go again.\n", player2.getName()); for(int i = 0; i <6; i++) { if(lettersGuessed[i] != 0) { lettersGuessed[i] = playerCheck; i = 6; } } Arrays.sort(lettersGuessed); } } else if(word.contains(playerInput)) { System.out.printf("Correct. %s you win a point!\n", player1.getName()); System.out.println(word); player1.iWon(); System.out.printf("%s: %d\t%s: %d\n\n", player2.getName(), player2.getScore(), player1.getName(), player1.getScore()); loopControlTwo = false; if(player2.getScore() == 0 || player1.getScore() == 0) { System.out.print("Game over. %s wins!\n"); loopControl = false; } } else { System.out.print("Incorrect. %s, you lose your turn.\n"); loopControlTwo = false; for(int i = 0; i < 6; i++) { if(lettersGuessed[i] == 0) { lettersGuessed[i] = playerCheck; i = 6; } Arrays.sort(lettersGuessed); } } } } } } } Similar TutorialsIm making a simple "gallow" guessing game. I got a virtual keyboard styled with boxes and onclick event, and a randomized guessing word when i click on button new game. Here is the virtual keyboard: Code: <div align="center" style="width: 700px; float: left;" id="keys"> <span onclick="selection(this)">Q</span> <span onclick="selection(this)">W</span> <span onclick="selection(this)">E</span> <span onclick="selection(this)">R</span> <span onclick="selection(this)">T</span> <span onclick="selection(this)">Z</span> <span onclick="selection(this)">U</span> ... all keys + a .css for looking like a keyboard - see picture at bottom</div> The function that randomizes a word from the array of words + css styled boxes around the word chars. the array of words: Code: var strings= [ "indexof", "round", "fixed", "touppercase", "alert", "prompt"]; Code: function newgame() { document.getElementById('display').innerHTML = ""; var wordArr = strings[Math.floor(Math.random() * strings.length)].split(""); for (var i=0; i<wordArr.length; i++) { document.getElementById('display').innerHTML += '<span>'+wordArr[i]+'</span>'; } } css for this words Code: #display span { border-top:1px solid #000; border-right:1px solid #000; border-bottom:1px solid #000; width:10px; background-color:gray; text-align:justify; padding:5px 10px; } #display span:first-child { border:1px solid #000; } I also have function to colorize the pressed key on virtual keyboard-that colors it red-so the user knows it pressed it already Code: function selection(key) { key.style.background = "red"; } So now i have the question how do i make the guessing word - the boxes around chars without the chars - that the boxes are empty, but somehow the word stays in back of it or something like that -temporary save?.. I mean now i got [f] [i] [x] [e] [d], i wanna when i press new game to be like [] [] [] [] [].. and then i need to guess the word.. i press e on keyboard.. then it comes like this [] [] [] [e] []... Somehow i need to check if the pressed key on the keyboard is inside the word, and then show it in the box (but how).. then i press f -> [f] [] [] [e] [] .... and so on till i guess all of the word.. Here is an screenshot if u dont know what i mean.. http://img13.imageshack.us/i/printscreenshot1.jpg/ Thank you for helping! Good day. I'm working on a word guessing game. Simple premise, enter a letter, if it's in the mystery word it fills the asterick if not you keep guessing until it is guessed. However, I can't get it to fill in the astericks or to acknowledge when you've guessed it...soem help would be appreciated...thanks in advance. ao5431 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Guessing Game</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> /* <![CDATA[ */ var mysteryWord = "suspicious"; function checkGuess() { if (document.forms[0].letter.value != "") { var progress = document.forms[0].mysteryWord.value; var guess = document.forms[0].letter.value; document.forms[0].letter.value = guess; mysteryWordArray = mysteryWord.split(" "); var progressArray = progress.split(""); for (var i=0; i<mysteryWord.length; ++i) { var curLetter = mysteryWordArray[i]; if (curLetter == guess) progressArray[i] = guess; } progress = progressArray.join(""); if (progress == mysteryWord) document.forms[0].mysteryWord.value = "You guessed correctly! The mystery word is '" + progress + "'."; else document.forms[0].mysteryWord.value = progress; } else window.alert("You must enter a letter!"); } /* ]]> */ </script> </head> <body> <h1>Guessing Game</h1><hr /> <form action="" method="get" enctype="application/x-www-form-urlencoded"> <p>Mystery word: <input type="text" name="mysteryWord" value="**********" size="100" readonly="readonly" style="border: 0" /></p> <p>Enter a letter and click the Submit Letter button.</p> <p><input type="text" name="letter" size="2" /> <input type="button" value="Submit Letter" onclick="checkGuess()" /></p> </form><hr /> </body> </html> Hey guys, I just started to create my first Javascript game. It is a platformer and i just cant figure out how to do the movement. ATM my "character" is just a black rectangle. Here is my code. I have not been able to find the bug. var c = document.getElementById("mainCanvas"); var ctx = c.getContext("2d"); var level1 = new Image(); level1.src = "Textures/level1.png" level1.addEventListener("load", function() {ctx.drawImage(level1, 0,0,1024,1024) ctx.fillRect(playerX, playerY, 55, 118)}) //Charecter Position var playerX = 512 var playerY = 512 //Render function playerRender() {ctx.fillRect(playerX, playerY, 55, 118)} window.addEventListener("keydown", function(evt){ if (evt.keycode == 87) {playerY-=10} }) var RenderPlayerInterval = setInterval(playerRender() ,10) Reply With Quote 01-25-2015, 12:34 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts Code: ctx.fillRect(playerX, playerY, 55, 118)}) //Charecter Position var playerX = 512 var playerY = 512 When you *CALL* that fillRect, neither playerX nor playerY has yet been defined! SO you are essentially doing Code: ctx.fillRect( null, null, 55, 118) And where are the semicolons on the end of EACH LINE. Yes, I know they aren't required. But put them in. It will save you from grief someday. Hi all, I am working on a hangman game and have got myself into a bit of muddle with designing the function that prompts the user to enter a letter and then checks it hasn't already been entered, if it has it asks them to enter a different letter. I basically want each letter that is entered to be added to the var allGuesses, then each new entry should be compared against this - however it's not looping at the moment and I don't really know where to go from here.. Am I close? Or miles off? function getInput(aString) { var allGuesses = ''; var inputCharacter = window.prompt("Pick a single lower-case character", "") while (inputCharacter == allGuesses.indexOf(-1)) { reInputCharacter = window.prompt("You have picked " + inputCharacter + " already. Pick another single lower-case character", "") } allGuesses = allGuesses + inputCharacter document.write(allGuesses) } Any advice would be much appreciated! Please delete, someone had a retard moment
I'm developing a simple game that involves a system of interconnected nodes with unidirectional travel between nodes (similar to the circulation system!). The goal of the game is to get from a starting node to an ending node, which can be a variable number of nodes away. The program picks a random starting point, then randomly chooses one of its connecting nodes (cNodes) and pushes it onto a pathArray. A cNode is randomly chosen from this new node and it is pushed onto the pathArray. This continues for a designated number of turns, thus generating a pathArray (invisible to the player). The last element in the pathArray is the endNode and the goal of the puzzle. At each node the player is given two options of travel (though there may be more than two ways to go). One of these options MUST be the correct way if the player has not deviated from the path up until that point. If the player has deviated, this option can be any cNode. The other node is any cNode that does not lead to the endNode. The following code contains a simplified list of nodes that represents the content in my game. The function, however, is taken word for word. In this snippet, the pathArray & startNode have already been generated and I am trying to resolve how to assign "nodeChoice" as either the correct direction of travel (for a player on the correct path) or any random cNode (for a player who has deviated from the path). Keep in mind that the pathArray and cNodes lengths can be any size. Code: <script> //NODES: var nodeA = {name:"A"}; var nodeB = {name:"B"}; var nodeC = {name:"C"}; var nodeD = {name:"D"}; var nodeE = {name:"E"}; var nodeF = {name:"F"}; var nodeG = {name:"G"}; var nodeH = {name:"H"}; var nodeI = {name:"I"}; var nodeJ = {name:"J"}; var nodeK = {name:"K"}; //An array of all nodes in the system: var systemArray = [nodeA, nodeB, nodeC, nodeD, nodeE, nodeF, nodeG, nodeH, nodeI, nodeJ, nodeK]; //Connecting Nodes (cNodes): //(uni-directional, but cyclical) nodeA.cNodes = [nodeB, nodeC]; nodeB.cNodes = [nodeD, nodeE, nodeF]; nodeC.cNodes = [nodeF, nodeG]; nodeD.cNodes = [nodeI, nodeH]; nodeE.cNodes = [nodeJ]; nodeF.cNodes = [nodeK]; nodeG.cNodes = [nodeK]; nodeJ.cNodes = [nodeA]; nodeK.cNodes = [nodeA]; nodeI.cNodes = [nodeA]; nodeH.cNodes = [nodeA]; //The path chosen (generated from code not included here) var pathArray = [nodeA, nodeB, nodeE, nodeJ]; //nodeChoice will represent a cNode from any given node var nodeChoice; //chooseNode is supposed to assign nodeChoice the next element in pathArray if the player on on the right path (if at nodeB, nodeChoice = nodeE). //However, if the user has taken a different path, its cNodes will not be in pathArray in which case a random cNode is assigned to nodeChoice function chooseNode(_node) { //check each cNode to see if any are in pathArray for (var j = 0; j < _node.cNodes.length; j++) { //if a cNode is in pathArray, then we know to assign it nodeChoice... if (_node.cNodes[j] in pathArray) { nodeChoice = _node.cNodes[j]; console.log("choiceNode CORRECT: " + nodeChoice.name); //(for debugging purposes only) } //...otherwise don't do anything in this forLoop/ifStatement }; //if by this point nodeChoice is still undefined, meaning none of the current node's cNodes are in pathArray, assign it any one of its cNodes. if (nodeChoice == undefined) { nodeChoice = _node.cNodes[Math.floor(Math.random()* _node.cNodes.length)]; console.log("choiceNode INCORRECT: " + nodeChoice.name);//(for debugging purposes only) }; }; //Runtime: chooseNode(nodeB); //Result should be only nodeE.name since nodeD is not in the pathArray... console.log(nodeChoice.name); </script> ...however, nodeChoice is assigned either D, E or F randomly and we are given the troubleshooting statement "choiceNode INCORRECT: D (or) E (or) F", indicating that the if-in statement is always ignored. I know that the if-in statement doesn't work but am not sure how else to write it so that each cNode is compared the each element in pathArray, both of which can be of variable lengths... Anyone know why my switchh statement isn't working? Code: var rehash = inward.location.hash.match(/[^#]/); switch(rehash) { case 1: rehash = 5; break; case 2: rehash = 1; break; case 3: rehash = 2; break; case 4: rehash = 3; break; case 5: rehash = 4; break; case null: rehash = 5; default: rehash = null; }; Code: if (rehash == 1) { rehash = 5; } else if(rehash == 2) { rehash = 1; } else if(rehash == 3) { rehash = 2; } else if(rehash == 4) { rehash = 3; } else if(rehash == 5) { rehash = 4; } else if(rehash == null) { rehash = 5; } else{rehash = "Invalid URL or REFERRER"} the if string works fine -_- i must be missing something Sorry about the title, I didn't know what else to use to describe my problem. Basically, I'm generating a random word with a function; then I'm trying to pass this word down to another function. The problem is, when I pass the word, it changes each time (due to it being randomly generated originally). I'm only calling the function once (via button click), but I'm also calling the function in my code lower down to retrieve the returned variable; and the function seems to be running again and returning a new word from my array. Here's a snippet of my code: Code: function ranNum(){ var ranNum = Math.round(Math.random()*10); var chosenWord = wordArray[ranNum]; return chosenWord; } function makeBoxes(x){ //remove children when new word is chosen var hM = document.getElementById("hangMan"); while(hM.firstChild){ hM.removeChild(hM.firstChild); } var chosenWord = ranNum(x); var wL = chosenWord.length; //create box for length of letters in word var i = 0; for(i=0;i<wL;i++){ var cBoxes = document.createElement("div"); cBoxes.className = "letterBoxes"; cBoxes.innerHTML = chosenWord.charAt(i); hangMan.appendChild(cBoxes); } return chosenWord; } function checkLetter(y){ var chosenWord = makeBoxes(y); alert(chosenWord); } So I generate a word with one button; now I need to be able to work with said word in my checkLetter() function. The word changes however. Any help would be greatly received. I found a nice script online that will count words. Problem is, I need it to also count each DIGIT (0-9) as a seperate word, whether the numbers are seperated by a space or not. I've searched this forum to no avail. Can anyone help me or show me how to do this, here is the original script: Code: <!-- TWO STEPS TO INSTALL WORD COUNT: 1. Copy the coding into the HEAD of your HTML document 2. Add the last code into the BODY of your HTML document --> <!-- STEP ONE: Paste this code into the HEAD of your HTML document --> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Original: Shawn Seley --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function CountWords (this_field, show_word_count, show_char_count) { if (show_word_count == null) { show_word_count = true; } if (show_char_count == null) { show_char_count = false; } var char_count = this_field.value.length; var fullStr = this_field.value + " "; var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi; var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, ""); var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi; var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " "); var splitString = cleanedStr.split(" "); var word_count = splitString.length -1; if (fullStr.length <2) { word_count = 0; } if (word_count == 1) { wordOrWords = " word"; } else { wordOrWords = " words"; } if (char_count == 1) { charOrChars = " character"; } else { charOrChars = " characters"; } if (show_word_count & show_char_count) { alert ("Word Count:\n" + " " + word_count + wordOrWords + "\n" + " " + char_count + charOrChars); } else { if (show_word_count) { alert ("Word Count: " + word_count + wordOrWords); } else { if (show_char_count) { alert ("Character Count: " + char_count + charOrChars); } } } return word_count; } // End --> </script> </HEAD> <!-- STEP TWO: Copy this code into the BODY of your HTML document --> <BODY> <form> <textarea cols=40 rows=5 name=x> </textarea> <br> <input type=button value="Count Words" OnClick ="CountWords(this.form.x, true, true);"> </form> <p><center> <font face="arial, helvetica" size"-2">Free JavaScripts provided<br> by <a href="http://javascriptsource.com">The JavaScript Source</a></font> </center><p> <!-- Script Size: 2.04 KB --> 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! This is a simple basic game i want to make. Its a "What Am I" Riddle... The questions is (In HTML which i already know): I'm as light as a feather but no man can hold me for long. What am I? the answer is: Your Breath. (This is where the JAVASCRIPT comes in) Lets say they guess a rock, have a pop up say: Wrong Answer. Please try again. Lets say they guess Your breath -OR- Breath, have a pop up say: Correct! I want a text field where you can enter your answer, and if they choose ANYTHING but the 2 correct answers above, it will display please try again. Can anyone code this please? Thanks for reading. hi there, I need to ask my users to input some numbers via textbox(or prompt) using a DELIMITER (,) between each digit. Then The program will display(list) when clicking a button. for this I will use three columns in the first column I have (2,4,6,9) to prompt. in the second column I have (3,4,7,10) to prompt. in the third columns I have (5,6,11,14) to prompt so the first lines should look like: 2,3,5 2,3,6 2,3,11 .... .... .... and the last line : 9,10,14 there should be 4x4x4=64 rows/lines How can we achieve this ? Thanks in advance public static void main(String[] args){ int oddNo; oddNo = getOdd(); } public static int getOdd(){ int oddNo = 0; Scanner sc = new Scanner(System.in); while (oddNo % 2 == 0){ System.out.print("Enter an odd number : "); oddNo = sc.nextInt(); System.out.println("Wrong input ! "); } if (oddNo % 2 !=0); System.out.print("The odd number is : " + oddNo); return oddNo; } however, the output: Enter an odd number : 10 Wrong input ! Enter an odd number : 8 Wrong input ! Enter an odd number : 9 Wrong input ! (how to remove this?) The odd number is : 9 I need to loop through an array like this one: [1,2,4,8,8,16,32,64] I don't really know how to do this, so a little guidance would be great. Basically, I have 4 vars: a b c and d in the form of (ax + b)(cx + d) inside the loop something like this: i++ a = array[i] If (a*b > Math.floor(a) && a*b < Math.ceil(a)){ then increment i again and do the loop again} else{ break the loop and set leave a = array[i] } A code sample or something would be really nice (I don't know how to do the parts that are written out in text... Thanks! } hi to all... good day to u all... i have a noob question i followed this instruction Code: for (count=1; count<11; count++) { javascript code here } at the bottom of my page i did this Code: <script type="text/javascript"> for (counter=1; counter<11; counter++) { var followTrigger+counter+a = new Spry.Widget.Tooltip('following'+counter+'a', '#followMe'+counter+'a', {followMouse: true}); } </script> what im trying to do is to make multiple of this Code: <script type="text/javascript"> var followTrigger1a = new Spry.Widget.Tooltip('following1a', '#followMe1a', {followMouse: true}); var followTrigger2a = new Spry.Widget.Tooltip('following2a', '#followMe2a', {followMouse: true}); var followTrigger3a = new Spry.Widget.Tooltip('following3a', '#followMe3a', {followMouse: true}); var followTrigger4a = new Spry.Widget.Tooltip('following4a', '#followMe4a', {followMouse: true}); var followTrigger5a = new Spry.Widget.Tooltip('following5a', '#followMe5a', {followMouse: true}); var followTrigger6a = new Spry.Widget.Tooltip('following6a', '#followMe6a', {followMouse: true}); var followTrigger7a = new Spry.Widget.Tooltip('following7a', '#followMe7a', {followMouse: true}); var followTrigger8a = new Spry.Widget.Tooltip('following8a', '#followMe8a', {followMouse: true}); var followTrigger9a = new Spry.Widget.Tooltip('following9a', '#followMe9a', {followMouse: true}); var followTrigger10a = new Spry.Widget.Tooltip('following10a', '#followMe10a', {followMouse: true}); </script> i dont know why it wont work... any help pls... I have a game page on my site and I am trying to protect direct access to it by .htaccess .htpasswd but is not accepting user name and password? .htaccess: AuthUserFile /home/vhosts/kandcoentertainment.freetzi.com/.htpasswd AuthType Basic AuthName "game1" <Files "cookietest.html"> Require valid-user </Files> .htpasswd test:8888 Any suggestions on why it is not working? What I would like to do is have apay and play once setup but as I am a novice and dont have a clue HELP PLEASE!!! What I have been told is - protect the files, add a client side cookie to game page then upon url payment return validate cookie giving single access and when played the user cannot replay by refresh or just typing in url because cookie expired ? I have tried to write the scripts up with no success. hat i'm trying to achieve is to add two numbers using do while loop. below is the code however result wont show up. i cant seem to determine the error. help me pls. Quote: <script = "text/javascript"> function myanswer(x,y){ x=parseInt(x); y=parseInt(y); i=1; sum=0; do { sum=x+i; i++; } while(i<y) document.myform.asnwer.value=sum; } </script> <form name='myform'> Enter First number:<input type='text' name='x'></br> Enter Second number:<input type='text' name'y'></br> Result:<input type='text' name='answer'></br> <input type='button' value='Click on Me!' onclick="myanswer(myform.x.value,myform.y.value);"</br> </form> Hi Guys, I am trying to create a game similar to this https://www.carchallenge2014.com/practice.php What I want to know is how can I run a script so that the script will be able to click on the hands and increase the score. Willing to pay for the help as well. Tks Hi, I have this code.. Code: javascript:function showMore() {ProfileStream.getInstance().showMore(); setTimeout(showMore, 2000)}; showMore(); i want to loop it 10 times, but do not know how to do it. I have been told that the for var command is what I want, but I cannot get it to work. Any help would be appreciated. Thanks I have a script where I can PregReplace soething in a string with a defined value from my input field and it works like a charm. Code: <?php echo '<input id="pfrom" type="text" value="" name="pfrom">'; ?> <script> function demoRegex(){ var txt = document.newform.thestring.value; var re = new RegExp(document.newform.pfrom.value, "g"); newtxt = txt.replace(re,''); alert(newtxt); } </script> But what if I have multiple input field like this: PHP Code: foreach($arr as $arr1=>$value){ echo '<input id="pfrom" type="text" value="" name="pfrom[]">'; } How do I get the javascript to run through all the fields? Hoping for help.... Thanks in advance ;-) |