Jump to content

husslela03

Members
  • Posts

    64
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

husslela03's Achievements

Member

Member (2/5)

0

Reputation

  1. Is there a way to maintain mySQL query results, if after I make a selection on a form, and then return to the page, to still have the other selections available? I run a query on a page, and then I created a form with radio boxes to select a person's name from the query result. I process the form, and then when I have a link that returns to the page, the query result list is no longer there. Is there a way to maintain persistance? Thanks.
  2. i have a function where I would like to compare two strings depending on the position of each letter I need to format each letter differently... if the letter is in the right place print it Red if the letter is in the word, but in the wrong place, print it in blue if it's not part of the word at all, make it black how would i do that with the function makeAGuess() below? Also, the printout needs to go in the "guessed" text box which i know i use document.myForm.guessed.value=... function makeAGuess() { var myInput=document.myLingo.input.value; document.myLingo.input.focus(); var cc= " "; if (!document.myLingo.input.value) { alert("Guess a letter.") } else { for(i=0; i<myInput.length; i++) { if(myInput.charAt(i)==theWord.charAt(i)) { document.myLingo.guessed.value=myInput.charAt(i).toUpperCase(); } else document.myLingo.guessed.value=myInput.charAt(i); } } } </script> </head> <body> <form name="myLingo"> <center> <table> <tr> <td> Lingo </td> </tr> <tr> <td align="right"> Get a New Word </td> <td align="left"> <input type="button" name="start" value="New Word" onclick="newGame()" /> </td> </tr> <tr> <td colspan=2 align="center"> <input type="text" name="toGuess" readOnly /> </td> </tr> <tr> <td colspan=2 align="center"> <input type="text" name="guessed" size="43" readonly> </td> </tr> <tr> <td colspan=2 align="center"> <input type="text" name="input" size=35> </td> </tr> <tr> <td colspan=2 align="center"> <input type="button" value="Make Guess" onclick="makeAGuess();"/> </td> </tr> <tr> <td align="right">Guess Count</td> <td align="left"> <input type="text" name="counter" value="" size=2 maxlength=2 disabled> </td> </tr> </table> </center> </form> </body> </html> Any help would be appreciated...
  3. I'm doing some string comparisons.... I would like to change the color of text entered based upon the comparisons in the string for instance here is some example code; for(i=0; i<input.length; i++) { if(myInput.charAt(i)==theWord.charAt(i)) { show letter in upper case letter in textbox } if(the letter is contained in the word i'm trying to match) { show it in blue } if(the word is not in the word i'm trying to match) { show it in black } } print the letter in the input box.... any help would be appreciated.. thanks
  4. Hello: I would like to display the first character of a word: like this: c _ _ _ _ and then all the rest is underline spaces i created this function but i do not know how to add in the theWord.charAt(0). I tried this: pattern += theWord.charAt(0) + " _ "; but i got this c _ c _ c _ .... which is not what i want function displayPattern(theWord) { var pattern= " "; for(i=0; i<theWord.length; i++) { if(theWord.charAt(i)==" ") { pattern += " "; } else pattern += " _ "; } document.myLingo.toGuess.value=pattern; Any help would be appreciated.
  5. So should i remove the onreadystatechange? do you have any other suggestions how to get the word into that m variable?
  6. Hello: I am trying to place a word that is chosen from a dictionary file chosen by using AJAX into another variable. The random word is selected in a .php file and retrieved with AJAX techniques. It is then placed into the xmlhttp variable. However i want to get it to work for when the "Start" button is clicked...the new game function is called, but the 'm' variable get's it's data from myfunction() where it calls the AJAX request. Any help would be great. <HEAD> <SCRIPT LANGUAGE="JavaScript"> var gameWord; var len=gameWord.length - 1; var xmlhttp; var m; function myfunction() { //variable to hold the word from the server if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if(xmlhttp.readyState==4) { gameWord=xmlhttp.responseText; } } xmlhttp.open("POST", "get_word.php", true); xmlhttp.send(null); } function newGame() { var badGuess="0"; var IntialInput=""; var x= new Array(); space=/ /g; myfunction(); m=gameWord; sweep(); diplayPattern(IntialInput); countRemain(badGuess); document.myForm.input.focus(); } function diplayPattern(inputChar){ var pattern =" "; for (i=0; i < m.length; i++) { if (m.charAt(i) == " ") { pattern += " "; } else if (inputChar.indexOf(m.charAt(i).toUpperCase()) != -1) { pattern += m.charAt(i).toUpperCase() + " "; } else pattern += "_ "; } document.myForm.toGuess.value=pattern; } function renameBut(myValue){ sweep(); } function sweep(){ for (i=0; i < document.theDetails.length - 1; i++) { document.theDetails.elements[i].value="";} for(i=3; i!=6 && i < document.myForm.length; i++) {document.myForm.elements[i].value=""} document.myForm.counter.value=""; } function winner(){ if (document.myForm.toGuess.value.indexOf("_ ") == -1) return true; } function displayDetails(){ for(i=0; i < gameWord.length; i++) { if (m == gameWord[i][0] ) { alert("You won. You are Genius!\n\n"+ "' " +m + " ' ' " + gameWord[i][1]+ " '"); for (j=0; j< gameWord[i].length ; j++) { document.theDetails.elements[j].value=" " + gameWord[i][j]; } } else if (m == gameWord[i][1]) { alert("You won. You are Genius!\n\n"+ "' " +m + " ' The Capital City is ' " + gameWord[i][0]+ " '"); for (j=0; j< gameWord[i].length ; j++) { document.theDetails.elements[j].value=" " + gameWord[i][j]; } } } } function countRemain(num){ myMatch=m.match(/\w/g); returnWord=m.match(/(\w|\s)/g); if (m.match(space) == null) {space_YorN=m.length;} else {space_YorN= m.length - m.match(space).length;} document.myForm.counter.value=space_YorN - (num.length-1) / 2; if (space_YorN - (num.length-1) / 2 <= "0") { alert("Oops! you lost. The word you missed is: \n\n \"" + m.toUpperCase() +"\"" ); document.myForm.toGuess.value=" "; for (i=0; i < m.length; i++) { document.myForm.toGuess.value += returnWord[i].toUpperCase() + " "; } } } function makeAGuess(){ var indx= new Array("a","b") var myInput=document.myForm.input.value.toUpperCase(); var cc=" "; else { if (!document.myForm.toGuess.value) { alert("Click on \"" +document.myForm.start.value +"\" Button."); }else { diplayPattern(myInput); document.myForm.input.focus(); if (!document.myForm.input.value) { alert("Guess a letter.") }else { if ((myInput.substring(0,myInput.length-1)).indexOf(myInput.charAt(myInput.length-1)) != -1) { alert("You already used << "+myInput.charAt(myInput.length-1)+ " >> \n Make another guess."); myInput=myInput.substring(0,myInput.length-1); document.myForm.input.value=myInput.toLowerCase(); } for (i=0; i<myInput.length; i++) { if (m.toUpperCase().indexOf(myInput.charAt(i)) == -1) {cc +=myInput.charAt(i) + " ";} } if (winner()) { displayDetails(); } } document.myForm.guessed.value=cc.toUpperCase(); countRemain(cc); } } } // End --> </script> </HEAD> <BODY onLoad="document.theDetails.gameLength.value=guessChoices.length;"> <div align=center> <table border=0 cellpadding=3> <tr> <td valign=top align=center><font size=7 face="arial black"><center>Lingo</center></font> <table border=0 cellpadding=9 cellspacing=0 bordercolor="black" bgcolor="#ffffc6" width=290> <form name="myForm"> <tr> </tr> </table><br> <div align=left> <font size="2" color="#685dab">Get A New Word</b></font><font size="2"><input type="button" name="start" value="Get New Word" onClick="newGame();"><p> <font size="3" face="arial"><center><input type="text" size="43" name="toGuess" readonly><br> <input type="text" name="guessed" size="43" readonly></center></font> <table><tr><td align=left> <font size=2 color="#685dab"> </font> </td></tr></table> <font size=2 color="#685dab"><b>c- </font><font size=3><input type="text" name="input" size=35></font> <input type="button" value="Submit Guess" onClick="makeAGuess();"><br> <!----> <div align=left> <font size=2 color=red></font> <font size=1 color="#000000"><i>You only have </i></font><font size=3 face=arial><input type="text" name="counter" value="" size=2 maxlength=2 disabled></font><font size=1 color="#000000"><i> bad guess before you lose!.</i></font> </form> </td></tr> <tr><td align=center valign="top"> </td> </tr> </table> </td> </tr> </table>
  7. so do you suggest not to close mysql() on each of the scripts and leave them open?
  8. Hello: I would like to navigate through different .php pages. I tried using the <a href> regular link and made sure that the session_start() was on all of the pages, however when i use the links, and return to prior pages, the mysql query is wiped out. How do maintain state when i return back to a page. For example: I query all the people that are in a class, then I click on a specific person to show that person's grades, but when i return back to the main class list, it's no longer there, the sql query is wiped out and doesn't rerun on page load. Thanks, husslela03
  9. so can i just use a regular html link tag then? and just make sure i put session_start() at the top?
  10. I would like to create a button for a user to click in which carries session data, however nothing is selected on a form that is selected...how would i do that? and i need to carry two session items...
  11. it worked! thank you so much! i might need you again shortly though!
  12. i'm having trouble returning a result for mySQL statement i have: $sql2=mysql_query("SELECT * FROM assignments, courses LEFT JOIN assignments ON (courses.courseID = assignments.courseID) LEFT JOIN grades ON (assignments.assignmentID = grades.assignmentID) WHERE (grades.userID='$userID' AND assignments.courseID='$courseName')"); I want to find all the grades in the grades table partaining to the student and the class chosen Here are my table structures Courses table: courseID courseName 1 Class A 2 Class B Assignments table: assignmentID courseID assignmentName assignmentMaxValue assignmentWeight 1 1 Homework1 100 10 2 1 Homework2 100 10 Grades table gradeID userID assignmentID score 1 1 3 96 2 2 3 85 The userID for the student is carried in the session along with the courseID Any help would be appreciated with my mySQL statement So i want to find all the grades for the student for the matching courseID.
  13. Hi: I'm currently attempting to write a word game. It grabs a word from the server by using a button, and then displays it with only the first letter, and then all the rest are blanks. I would like to know the best way to set this us, because when I do a request using AJAX within a javascript function, it completely wipes out the page and just shows the word. Any help would be appreciated of where to start. I can do the rules myself, I just need help with the setup.
  14. <?php echo 'Welcome to Lingo'; ?> <html> <head> </head> <body> <script type="text/javascript"> var xmlhttp; var gameWord; function myfunction() { //variable to hold the word from the server if(window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(var gameWord) { if(xmlhttp.readyState==4) { document.getElementById('word').innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST", "get_word.php", true); xmlhttp.send(null); } document.write(gameWord); </script> <form name="myLingo"> <input type="button" value="New Word" onclick="myfunction()" /> <div id="word"> </div> </form> <center> LINGO </center> </body> </html> what i would really like to do is have a button that gets the word from the dictionary file that i have set up with php and mySQL, then when the word first displays, I want to show blanks first, however if I can't get it in a variable to manipulate it, i can do the rest...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.