...

View Full Version : javascript put in order



JoshEnce
01-02-2012, 05:17 PM
I have a challenge I gave to myself. I want a script that asks me to put things in order. Say I want a quiz of family, order of age. I have a table with the left cell everybody's name I want a script where I click on a name and it moves over to the right hand cell, up top, then the next clicked named is put under it and so on until all the names are moved over. So far I have this, but I know there is a lot of room for improvment. any suggestions?
<HTML>
<HEAD>
<TITLE>Put Bible books in proper order</TITLE>
</head>

<body>
<h1>Hello World!</h1>
<TABLE BORDER=5><TR><TD>
<FORM NAME="BOOKS">
<script language="javascript" type="text/javascript">
alert('This is what an alert message looks like.');
FUNCTION TESTER() {
ALERT('WORKS');
VAR GOOD=0;
VAR BAD=0;
if (BOOKS.FONE="A") {
GOOD++;
}
ELSE {
BAD++;
};
ALERT("YOU HAVE INCORRECT");
}
</script>

<TABLE BORDER=0><TR><TD>

<TABLE BORDER=1>
<TR><TD><INPUT TYPE="BUTTON" VALUE="Adam" NAME="GONE" onClick="javascript:TEMP.value=this.value";>
<TR><TD><INPUT TYPE="BUTTON" VALUE="Dave" NAME="GTWO" ONCLICK="javascript:TEMP.value=this.value";>
<TR><TD><INPUT TYPE="BUTTON" VALUE="Kile" NAME="GTHREE" ONCLICK="javascript:TEMP.value=this.value";>
<TR><TD><INPUT TYPE="BUTTON" VALUE="John" NAME="GFOUR" ONCLICK="javascript:TEMP.value=this.value;">
<TR><TD><INPUT TYPE="BUTTON" VALUE="Geroge" NAME="GTWO" ONCLICK="javascript:TEMP.value=this.value;">
</TABLE>

<TD VALIGN="CENTER" ALIGN="CENTER" WIDTH=30>
<INPUT TYPE="BUTTON" VALUE=" " NAME="TEMP">
<TD>

<TABLE BORDER=1>
<TR><TD><INPUT TYPE="BUTTON" VALUE="?????" NAME="FONE" ONCLICK="javascript:this.value=TEMP.value;TEMP.value=' '">
<TR><TD><INPUT TYPE="BUTTON" VALUE="?????" NAME="FTWO" ONCLICK="javascript:this.value=TEMP.value;">
<TR><TD><INPUT TYPE="BUTTON" VALUE="?????" NAME="FTHREE" ONCLICK="javascript:this.value=TEMP.value;">
<TR><TD><INPUT TYPE="BUTTON" VALUE="?????" NAME="FFOUR" ONCLICK="javascript:this.value=TEMP.value;">
<TR><TD><INPUT TYPE="BUTTON" VALUE="?????" NAME="FFIVE" ONCLICK="javascript:this.value=TEMP.value;">
</TABLE>

</TABLE>
<INPUT TYPE="BUTTON" NAME="CHECK" onClick="JAVASCRIPT:ALERT()" VALUE="CORRECT???">


</FORM>
</TABLE>
</BODY>
</HTML>

Old Pedant
01-02-2012, 09:43 PM
All of this code:

FUNCTION TESTER() {
ALERT('WORKS');
VAR GOOD=0;
VAR BAD=0;
if (BOOKS.FONE="A") {
GOOD++;
}
ELSE {
BAD++;
};
ALERT("YOU HAVE INCORRECT");
}
is completely bogus. JavaScript is CASE SENSITIVE and all keywords in JavaScript must be in lower case.

Examples: function, alert, var.

********

Is this homework for some class?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum