Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using GetElementById method

843840Jul 17 2008 — edited Jul 21 2008
hi!

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!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2008
Added on Jul 17 2008
6 comments
345 views