I want to make a javascript to be shown if somebody chooses option A to show the javascripts for the A1 , A2 , A3 and if they choose B to show javascripts for the B1 , B2 , B3. So the A and B it will firstly asked as options from a select tag
For example:
<select name="AorB" >
<option value="" selected="selected">Select...</option>
<option value="A" >Option A</option>
<option value="B" >Option B</option>
</select>
I’m using this way of javascript (Error Alerts):
<SCRIPT language=JavaScript>
<!--
function check(form) {
if (form.Password.value == "")
{ alert("Please enter your Password."); form.Password.focus(); return;}
if (form.Password.value.length < 8)
{ alert("Please enter a valid Password."); form.Password.focus(); return;}
form.submit()
}
//-->
</SCRIPT>
P.S: I don’t want to make complications when they choose A to get B option javascripts or reverse.
added – explain: i mean if We select OPTION A there will be shown some Input-s ….and javascript will ask only for the shown input-s so it means OPTION A input-s … but not to ask for OPTION B input-s too even that they’re not shown cause we didnt select OPTION B … i hope i explained a little for you.
What I understand of your question is that you want a select box and this will determine what fields show up on the form. Then you want the validation script to only validate those fields that show up. This would best be handled with JQuery. Here is some working code to give an example, and a fiddle.
HTML
JQuery