Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

toggle radio button via getElementById

Status
Not open for further replies.

Bastien

Programmer
May 29, 2000
1,683
CA
All

I am trying to see if I can toggle a radio button as below with a document.getElementById("buttonId").checked=true. There are 25 buttons on the page as below.

I seem to have some issues with this. Is this the right approach or do I need to loop thru the radio buttons and check for the id?

Code:
<tr class='reportrows1'><td noWrap>
  <input type='radio' id='221234' name='hierarchy_selection'  onclick='javascript:document.getElementById("").value="221234";return true;'>
&nbsp;<a onclick='doit(document.getElementById("_details_221234"));document.getElementById('221234').checked=true;'></a>
</td>
</tr>
<tr id='_details_221234' style='display: none'>
  <td><b>Chain&nbsp;:</b>&nbsp;22
      <BR><b>Zone&nbsp;:</b>&nbsp;99
      <BR><b>Region&nbsp;:</b>&nbsp;99
      <BR><b>District&nbsp;:</b>&nbsp;99
      <BR>
  </td>
</tr>

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
You are trying to set the status of a radio button from a link, however the link is empty, so how exactly do you expect to click it if there's nothing there?


What exactly are you trying to do?

Looks like you want to get the radio button to be checked when a text related to it is clicked.

Why not use a label instead, that already works like that, instead of trying to reinvent the wheel?

Code:
<label for="122345">check me</label><input type=radio id="122345" name="aradiobtn">


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Link is empty due to bad copy'n'paste. Sorry. I will try the label approach


Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
worked like a charm.... damn inheirited code

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Glad it worked for you.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top