PDA

View Full Version : can u solve my problem in javascript


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>

Vladdy
08-16-2002, 01:08 PM
Yes I can...

See my page: http://www.vladdy.net/webdesign/DOM_Tables.html

phani
08-16-2002, 01:49 PM
can u please modify the code i send to u. i can't understand the code given in the site.

Vladdy
08-16-2002, 06:22 PM
The link I gave, describes a different approach to constructing and manipulating tables. It shows how to dynamically create a table and how to access it's elements.

While you may be able to show/hide rows using your code and applying it to TR element, changing rows order is another task and my page shows how it can be accomplished.

If your knowledge of JavaScript is not up to the task you can hire me to provide you with turn-key solution.