I have 2 simple radio button. Clicking 2nd radio button displays a drop down.
If nothing has been picked from a drop down when radio button 2 has been clicked the page should not be submitted.
I have some code that toggles the display of the drop down depending on which radio button is clicked.
So I have 2 radio buttons like this -
- 1 Radio Button
- 2 Radio Button
and one drop down that only shows up when radio 2 is clicked.
Here is my code -
For some reason when I click the 2nd radio button twice the drop down disappears and even though the drop has disappeared no value has been clicked but the page still submits.
When I do an alert(document.thisform.dropdown.selectedIndex)the value is 0 and the page submits.
I hope I explained it well. Any help.
If nothing has been picked from a drop down when radio button 2 has been clicked the page should not be submitted.
I have some code that toggles the display of the drop down depending on which radio button is clicked.
So I have 2 radio buttons like this -
- 1 Radio Button
- 2 Radio Button
and one drop down that only shows up when radio 2 is clicked.
Here is my code -
Code:
if(document.thisform.radio[1].checked == true)
{
if(document.thisform.dropdown.selectedIndex == 0 )
{
alert('Please Pick one value from dropdown')
return false;
}
}
For some reason when I click the 2nd radio button twice the drop down disappears and even though the drop has disappeared no value has been clicked but the page still submits.
When I do an alert(document.thisform.dropdown.selectedIndex)the value is 0 and the page submits.
I hope I explained it well. Any help.