phani
08-16-2002, 08:20 AM
hi,
iam having a problem in javascript related to display of the fields in the table. suppose i want to display some rows of the table depending upon the option i have selected. i got it with out using table, but its not getting using the tables. here is sample code i worked out. The order of rows is also changing.
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">
function toggle_display(val) {
if (val=="fg") {
txt_answer.style.display=""
txt_choose.style.display="none"
}
else if (val="mc") {
txt_answer.style.display="none"
txt_choose.style.display=""
}
}
</script>
</head>
<body>
<form>
<table border="0">
<tr>
<select name="inputbox1">
<option value="c" selected>c</option>
<option value="c++">c++</option>
<option value="vb">vb</option>
</select>
</tr>
<tr>
<select name="inputbox2" onchange="toggle_display (this[this.selectedIndex].value)">
<option value="mc">multiple choice</option>
<option value="fg" selected>fill in the gaps</option>
</select>
</tr>
<tr>
<td>Question: </td>
<td><textarea name="question" rows="6" cols="50">
</textarea>
</td>
</tr>
<div id="txt_answer" style="display:'';">
<tr>
<td>Answer: </td>
<td><textarea name="answer" rows="6" cols="40" >
</textarea>
</td>
</tr>
</div>
<div id="txt_choose" style="display:none;">
<tr>
<input type="text" name="choice1" value="choice1">
</tr>
<tr>
<input type="text" name="choice2" value="choice2">
</tr>
<tr>
<input type="text" name="choice3" value="choice3">
</tr>
<tr>
<input type="text" name="choice4" value="choice4">
</tr>
</div>
<tr>
<input type="submit" value="DONE">
</tr>
</table>
</form>
</body>
</html>
iam having a problem in javascript related to display of the fields in the table. suppose i want to display some rows of the table depending upon the option i have selected. i got it with out using table, but its not getting using the tables. here is sample code i worked out. The order of rows is also changing.
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">
function toggle_display(val) {
if (val=="fg") {
txt_answer.style.display=""
txt_choose.style.display="none"
}
else if (val="mc") {
txt_answer.style.display="none"
txt_choose.style.display=""
}
}
</script>
</head>
<body>
<form>
<table border="0">
<tr>
<select name="inputbox1">
<option value="c" selected>c</option>
<option value="c++">c++</option>
<option value="vb">vb</option>
</select>
</tr>
<tr>
<select name="inputbox2" onchange="toggle_display (this[this.selectedIndex].value)">
<option value="mc">multiple choice</option>
<option value="fg" selected>fill in the gaps</option>
</select>
</tr>
<tr>
<td>Question: </td>
<td><textarea name="question" rows="6" cols="50">
</textarea>
</td>
</tr>
<div id="txt_answer" style="display:'';">
<tr>
<td>Answer: </td>
<td><textarea name="answer" rows="6" cols="40" >
</textarea>
</td>
</tr>
</div>
<div id="txt_choose" style="display:none;">
<tr>
<input type="text" name="choice1" value="choice1">
</tr>
<tr>
<input type="text" name="choice2" value="choice2">
</tr>
<tr>
<input type="text" name="choice3" value="choice3">
</tr>
<tr>
<input type="text" name="choice4" value="choice4">
</tr>
</div>
<tr>
<input type="submit" value="DONE">
</tr>
</table>
</form>
</body>
</html>