0

I need to make a form with a few options could be radio or drop down, ex a, b, and c..
and when one is selected I would have a if command that would give you another set of options like if option "a" is selected then in the same page would come up another set of options like a1, a2, a3.. or if "b" is selected then options b1, b2, b3 and so on..

thanks for the help..

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by phpl0v3r
0

HTML

<select name="select1" id="select1" onChange="return changeForm();">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<select name="select2" id="select2">
</select>

JavaScript

function changeForm(){
var a = document.getElementById("select1");
var b = document.getElementById("select2");
var c = a.options[a.selectedIndex].value;
if(c == 1){
b.innerHTML = '<option value="1.1">1</option><option value="1.2">2</option>';
}
if(c == 2){
b.innerHTML = '<option value="2.1">1</option><option value="2.2">2</option>';
}
if(c == 3){
b.innerHTML = '<option value="3.1">1</option><option value="3.2">2</option>';
}
}

Edited by phpl0v3r: n/a

0

so all I have to do is put the form values i want for the 2nd set of options in the b.innerHTML field?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.