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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select all yes with mutiple radio button

Status
Not open for further replies.

jadec

MIS
Jan 22, 2004
87
0
0
US
Hi Everyone,

I have a page have mutiple rows, each row have a set of button, 2 buttons per set, one for yes, one for no. they have same name. But buttons in different row has different names. I want to create a "Select All Yes" button, when I click it, all rows will select yes button. Please help !!!!!


 
here's a quick and dirty way:

Code:
function doSelect( v, f ) {
    var e = f.getElementsByTagName("input");
    for ( var i = 0; i < e.length; i++ ) {
        if ( e[i].type == 'radio' && e[i].value == v )
            e[i].checked = true;
    }
}

Code:
<input type="button" value="select all 'yes'" onclick="doSelect('yes', this.form);" />
<input type="button" value="select all 'no'" onclick="doSelect('no', this.form);" />


make sure all appropriate radio buttons have a value of "yes" ...



*cLFlaVA
----------------------------
[tt]( <P> <B>)[sup]13[/sup] * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thank you for your replay, cLFlaVA. Please my code below. Buttons in each row have different name.

Code:
<table>
<tr>
  <td>aaaaaa</td>
  <td>
    <table>
      <tr>
         <td><input type="button" value="Y" name=[COLOR=blue]"SEL1"[/color] />yes<td>
         <td><input type="button" value="N" name=[COLOR=blue]"SEL1"[/color] />No<td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td>bbbbb</td>
  <td>
    <table>
      <tr>
         <td><input type="button" value="Y" name=[COLOR=blue]"SEL2"[/color]/>yes<td>
         <td><input type="button" value="N" name=[COLOR=blue]"SEL2"[/color] />No<td>
      </tr>
    </table>
  </td>
</tr>
<tr>
  <td>cccccc</td>
  <td>
    <table>
      <tr>
         <td><input type="button" value="Y" name=[COLOR=blue]"SEL3"[/color]/>yes<td>
         <td><input type="button" value="N" name=[COLOR=blue]"SEL3"[/color] />No<td>
      </tr>
    </table>
  </td>
</tr>
</table>

<table>
<tr>
 <td><input type="button" value="Select All Yes" onclick="selectall()" /></td>
</tr>
</table>

How do I code my selectall() function? Please advise!


 
Thanks cLFlaVA!

I got it. Works Perfect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top