...

View Full Version : Forms



Emma
09-22-2002, 09:50 PM
Hi there,

Hoping someone can help me?

I'm after some code whereby when a user clicks on an answer to a question either a 'tick' or a 'cross' appears and stays to show whether the answer the user has selected is correct or not.

Can anyone help me?

Cheers, EM

Nightfire
09-23-2002, 01:20 AM
:confused: The point of the poll is...?

You have server side support on your host?

Emma
09-23-2002, 01:33 AM
Sorry maybe I didn't explain myself properly.

When a word is 'clicked' on I want a picture to appear and to remain on screen.

I don't know a lot about html, and I am currently using Frontpage 2000, which I'm sure you will think ?????, but thought it was worth asking, its the only way I will find out.

If this is the wrong place for this, please accept my apology and ignore this.

E:o

Mr J
09-24-2002, 11:32 PM
Something on the lines of this:



<HTML><HEAD><TITLE>Take Your Pick</TITLE>

<SCRIPT language=JavaScript>
<!--
which=null
no_match=0
pick=new Array() //
pick[pick.length] = new Array("red","herring","flag","alert",3)
pick[pick.length] = new Array("silver","spoon","lining","mine",1)
pick[pick.length] = new Array("tea","spoon","bag","cup",2)
pick[pick.length] = new Array("sun","flower","tan","spot",1)
pick[pick.length] = new Array("treasure","island","chest","trove",2)
pick[pick.length] = new Array("sweet","corn","tooth","pea",3)
pick[pick.length] = new Array("tooth","brush","paste","fairy",3)



function Auto_Enter_Word(n){
aaa=pick[n][0]
Enter_Word()
}


function Enter_Word(){
no_match=0
note.innerHTML=""

clearRads()

for(i=0;i<pick.length;i++){
if(pick[i][0]==aaa){
no_match=1
which=i
document.opt.choice1.value=pick[i][1]
document.opt.choice2.value=pick[i][2]
document.opt.choice3.value=pick[i][3]
}
}

if(no_match==0){
note.innerHTML="\"<b>"+aaa+"</b>\" is not in the list"
document.opt.reset()
}
else{
note.innerText="&nbsp;"
}
}

function clearRads(){ // check radios not selected
for(i=0;i<document.opt.answer.length;i++)
if (document.opt.answer[i].checked==true){ // if selected
document.opt.answer[i].checked=false // deselect
}
}

function Match_Word(){
if(no_match==0){return}
if(which==null){return}

for(j=0;j<document.opt.answer.length;j++){
if(document.opt.answer[j].checked==true){

if(document.opt.answer[j].value=="choice"+pick[which][4]){
note.innerHTML="\"<b><font color='green'>"+pick[which][j+1]+"</b></font>\" is correct"
//alert(document.opt.answer[j].value+" = " +pick[which][j+1])
}
else{
note.innerHTML="\"<b><font color='red'>"+pick[which][j+1]+"</b></font>\" is not correct"
}
}

}
}

//-->
</SCRIPT>
</HEAD><BODY>
<center>
<FORM name=opt>
<table border="1">
<tr><td>&nbsp;</td><td>Reference 1</td><td>Reference 2</td><td>Reference 1</td></tr>
<tr><td>
<select onChange="Auto_Enter_Word(options[selectedIndex].value)">
<option></option>
<option value="0">Red
<option value="1">Silver
<option value="2">Tea
<option value="3">Sun
<option value="4">Treasure
<option value="5">Sweet
<option value="6">Tooth
</select></td>
<td><INPUT name="choice1" size="12"></td><td><INPUT name="choice2" size="12"></td><td><INPUT name="choice3" size="12"></td></tr>

<tr align="center"><td><INPUT type="reset" value="Reset"></td><td><input type="radio" name="answer" value="choice1" onclick="Match_Word()"></td>
<td><input type="radio" name="answer" value="choice2" onclick="Match_Word()"></td>
<td><input type="radio" name="answer" value="choice3" onclick="Match_Word()"></td></tr>
<tr><td colspan="4"><div id="note">&nbsp;</div></tr>
</table>
</center>
</FORM>

</BODY></HTML>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum