Using GetElementById method
843840Jul 17 2008 — edited Jul 21 2008hi!
i just want to ask if it is possible to use the getElementById method if my radio button id is a variable? i need to get the value of the radio button that the user will select.here is my code for radio button:
<% int num=2;
for (int i=0;i<=num;i++){
String radioid = "radio" + i;
%>
<TR><TD><input type=radio id="<%=radioid %>" name=rtraining value="<tracking:displayTraining />" onclick="check()">hello</TD></TR>
<%
} %>
and here is my javascript function:
function check()
{
var rvalue = document.getElementById();
if (rvalue!=null){
document.write(rvalue.innerHTML);
}else{
document.write("Error!");}
}
if you can give me another way to get the radiobutton value, that will be a big help.
please help me.im just new to java.
any response is very much appreciated. thank you!