for my class I recently wanted to code a vocabulary-learn and test site.
My concept was to have a "learn-page" where all vocabluarys are listed, in german and english (we are from germany), that one works with no problem, the "test-page" should be structured like this: on one column there are the german words listed, right next to each in the other column there is a textbox in which the user shall enter the right solution. Another column on the righht there is a "check" button near each textbox, named "check".
You need to know that I'm using a MySQL-Table with 3 columns: ID, Englisch, German, on the learning and on the testing page I'm using "SELECT * FROM vocabluarys....".
The textbox got the name "id" (the current ID of the mysql fetch array).
About the check-button (and the problem):
I wanted the check-button to call via onclick a java-script function with 2 parameters: ids and englishvalue.
Why these two?
ids: I wanted the ids-parameter to receive the current ID of the mysql-fetch-array to use that parameter for getting the value of the textbox.
englishvalue: This one should contain the true english value from the mysql table.
The error: I don't know, after hitting the button nothing happens.
Codes:
The javascript on the header of the .php file:
Quote
function checks(ids, valueenglish){
x=document.getElementByName(ids).value;
if(x!=valueenglish)
{
alert("Wrong");
}
else
{
alert("Right");
}
}
x=document.getElementByName(ids).value;
if(x!=valueenglish)
{
alert("Wrong");
}
else
{
alert("Right");
}
}
the mysql-fetch-array "while" solution for the textbox and button:
Quote
echo "<td bgcolor='4C4C4C'><input type='text' name='".$row[id]."' style='background: black; color: white;'></td>";
echo "<td bgcolor='4C4C4C'><input type='button' onclick=checks('".$row[id]."', '".$row[englisch]."') value='Check'></td>";
echo "<td bgcolor='4C4C4C'><input type='button' onclick=checks('".$row[id]."', '".$row[englisch]."') value='Check'></td>";
any ideas?
I only know PHP HTML JavaScript and MySQL, don't come along with other languages if possible.
Post has been edited 2 time(s), last time on Sep 17 2009, 5:14 am by DeVouReR.
Please report errors in the Staredit.Network forum.