jerry4all
12-17-2011, 03:43 PM
Another task please...I need to display the appropriate div when a radio button is selected...
<body>
<script type="text/javascript">
function checkjob(jobvalue){
if(jobvalue="type") {
document.getElementById("type").style.display = "block";
}else if(jobvalue="select"){
document.getElementById("select").style.display = "block";
}else if(jobvalue="tag"){
document.getElementById("tag").style.display = "block";
}
}
</script><br />
<table width="200">
<tr>
<td><label>
<input type="radio" name="cat" value="type" id="cat_0" onchange="checkjob(this.value)" />
type</label></td><td><label>
<input type="radio" name="cat" value="select" id="cat_1" onchange="checkjob(this.value)" />
select</label></td>
<td><label>
<input type="radio" name="cat" value="tag" id="cat_2" onchange="checkjob(this.value)" />
tag</label></td>
</tr>
</table>
<div id="type" style="display:none"><input name="contact" type="text" /></div>
<div id="tag" style="display:none">tag:<input name="contact" type="text" /></div>
<div id="select" style="display:none"><select name="">
<option value="a" selected="selected">option 1</option>
<option value="b">option 2</option>
</select></div>
</body>
<body>
<script type="text/javascript">
function checkjob(jobvalue){
if(jobvalue="type") {
document.getElementById("type").style.display = "block";
}else if(jobvalue="select"){
document.getElementById("select").style.display = "block";
}else if(jobvalue="tag"){
document.getElementById("tag").style.display = "block";
}
}
</script><br />
<table width="200">
<tr>
<td><label>
<input type="radio" name="cat" value="type" id="cat_0" onchange="checkjob(this.value)" />
type</label></td><td><label>
<input type="radio" name="cat" value="select" id="cat_1" onchange="checkjob(this.value)" />
select</label></td>
<td><label>
<input type="radio" name="cat" value="tag" id="cat_2" onchange="checkjob(this.value)" />
tag</label></td>
</tr>
</table>
<div id="type" style="display:none"><input name="contact" type="text" /></div>
<div id="tag" style="display:none">tag:<input name="contact" type="text" /></div>
<div id="select" style="display:none"><select name="">
<option value="a" selected="selected">option 1</option>
<option value="b">option 2</option>
</select></div>
</body>