...

View Full Version : Question & Answer Form



Luzzy
12-17-2006, 03:27 PM
I have been to a website offering free scripts and managed to find a Question & Answer form.
The script works fine except for the 'answer' section which is continually blank. I am able to change the questions but not the answers. Can anyone see the error in the script. Any help appreciated.


<form name="form1"> <table border="0"> <tr>
<td> <script language="JavaScript"> <!-- This script
supplied free by ************** http://www.************** --> <!-- function
showAnswer(whatForm){ if(document.forms[whatForm].question.value=="none"){
document.forms[whatForm].answer.value="^ Please select a question above ^"
}else{ document.forms[whatForm].answer.value=document.forms[whatForm].question.value
}} // --> </script> <b>Please select a question:</b> </td>
<td valign="top"> <select name="question" size="1"
onChange="showAnswer('form1')"> <option value="none">
</option> <option value="Your answer!">Your question?</option>
<option value="Your answer!">Your question? </option> <option
value="Your answer!">Your question?</option> <option value="Your
answer!">Your question?</option> </select> </td> </tr>
<tr> <td align="right"><b>Here is your answer:</b>
</td> <td> <textarea name="answer" rows="8"
cols="40" readonly></textarea> </td> </tr> </table>
</form>

j9ine
12-17-2006, 10:57 PM
<html>
<head>
<script type="text/javascript">
function showAnswer(whatForm) {
if (document.forms[whatForm].question.value=="none") {
document.forms[whatForm].answer.value="^ Please select a question above ^";
} else {
document.forms[whatForm].answer.value=document.forms[whatForm].question.value;
}
}
</script>
</head>
<body>
<form name="form1">
<table border="0">
<tr>
<td>
<b>Please select a question:</b>
</td>
<td valign="top">
<select name="question" size="1" onChange="showAnswer('form1');">
<option value="none">
<option value="Your answer1!">Your question1?
<option value="Your answer2!">Your question2?
<option value="Your answer3!">Your question3?
<option value="Your answer4!">Your question4?
</select>
</td>
</tr>
<tr>
<td align="right">
<b>Here is your answer:</b>
</td>
<td>
<textarea name="answer" rows="8" cols="40" readonly></textarea>
</td>
</tr>
</table>
</form>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum