Hope this will work for you function submitting() { if(document.f.mst1[0].checked) alert("Single is Selected from mst1"); if(document.f.mst1[1].checked) alert("Married is selected from mst1");
if(document.f.mst2[0].checked) alert("Single is Selected from mst2"); if(document.f.mst2[1].checked) alert("Married is selected from mst2");
if(document.f.mst3[0].checked) alert("Single is Selected from mst3"); if(document.f.mst3[1].checked) alert("Married is selected from mst3");
if(document.f.mst4[0].checked) alert("Single is Selected from mst4"); if(document.f.mst4[1].checked) alert("Married is selected from mst4");
} </script> <form name="f">
Single<INPUT type="radio" name="mst1" >Married<INPUT type="radio" name="mst1" > Single<INPUT type="radio" name="mst2">Married<INPUT type="radio" name="mst2"> Single<INPUT type="radio" name="mst3">Married<INPUT type="radio" name="mst3"> Single<INPUT type="radio" name="mst4">Married<INPUT type="radio" name="mst4"> add one submit/button and specify onclick method in this case it is submitting() </form>
sonu rai
Greenhorn
Joined: May 23, 2007
Posts: 22
posted
0
hi No this can't help me ,The radio buttons name are changed dynamically.
such as Single<INPUT type="radio" name="mst12" value="single">Married<INPUT type="radio" name="mst1" value="married"> Single<INPUT type="radio" name="mst2" value="single">Married<INPUT type="radio" name="mst2" value="married">
the name of radio buttons mst1,mst2 (1,2) is to be changed dynamically, because the buttons may can increase by adding a row.if the 3rd button comes than what can i do. if i write var x = document.myForm.mst3.checked; it is ok for mst3 suppose 1 button increses than how could i get mst4
Jay Damon
Ranch Hand
Joined: Jul 31, 2001
Posts: 279
posted
0
Why not loop thru the possibilities? I have not tested the following code but it sounds as if you need to do something similar to the following:
The key is to add consistent id attribute values to your radio buttons. If you need to access the buttons for a specific row, then you will need to pass the row index via an event handler.