I want to set the value to the radiobutton dynamically.How it possible

Hi all,

I want to set the value to the radio button dynamically.but its giving undefined.

below is the code...

<table>

while(rSet.next())

{

String sim=rSet.getString(1);

System.out.println("the sim value is:"+sim);

%>

<tr class="forsmalllabel">

<td><input type="radio" name="acsRadio"

value="<%=rSet.getString(1).toString().trim() %>"onClick="validate(this.form)" > </td>

</tr>

<% } %>

</table>

sim variable giving the correct value ...but here ..

whenever I am clicking on the button..it giving undefied message.

my script is below..

<script language="javascript">

function validate(value)

{

alert("the value is:"+document.ASCCodeform.acsRadio.value);

return true;

}

</script>

any one help me on this..

urgent.

Thank you,

D.Nagireddy.

[982 byte] By [Nagireddy_javaDevelopera] at [2007-10-2 15:42:38]
# 1
You didn't post the whole code so I can't see the form element. I was wondering if by any chance, you are using the wrong form name when you get the undefined message? Is your form name ASCCodeform? Since your radio button is acsRadio maybe your form name is ACSCodeform.
Gita_Weinera at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
yes u r correct.form name is: ASCCodeformbutton name: acsRadio
Nagireddy_javaDevelopera at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
i think u have to write it this way to access the value of radio button...document.ASCCodeform.acsRadio[x].valuewhere x is equal to the index of the selected value
swish-swisha at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
swish is correct, it can be an array of radio button or a single button. If you have created more than one radio button your will have to usedocument.ASCCodeform.acsRadio[x].valuebut if it is only one you will make it:document.ASCCodeform.acsRadio.value
jgalacambraa at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
yes.I got that one.I am trying to get the same radio button value in servlet.its not getting.is there any other way.the code is same like what we are getting text value.req.getParameter("acsRadio");its not getting in servlet.
Nagireddy_javaDevelopera at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
usereq.getParameters("acsRadio");
swish-swisha at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
thanks a lot SWISHworking....................
Nagireddy_javaDevelopera at 2007-7-13 15:30:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...