Results 1 to 2 of 2

Thread: how do I refer two forms to the same function?

  1. #1
    Join Date
    May 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how do I refer two forms to the same function?

    This function brings up the only raws selected when I click compare. The problem is that I have the same form twice. How can solve this?
    Code:
    <html>
    
    <head>
    <script type="text/javascript">
    <!--
    window.onload=function()
    {
        document.getElementById('onclick').onclick=function()
        {
        var check=document.getElementsByTagName('input'),
        divs=document.getElementsByTagName('tr'),i=0;
        for(var i;i<check.length,i<divs.length;i++)
        {
        divs[i].style.display='none';
        if(check[i].type=='checkbox')
            {
            if(check[i].checked==true)
            divs[i].style.display='';
            }}}}
    //-->
    </script>
    </head>
    
    <body>
    
    <form><label></label><label></label>
      <table width="953" border="1">
      <tr id="dd1">
        <td width="829" >1</td>
        <td width="108" ><input type="checkbox" name="modtype2" value="value1" />
          <label>value1</label></td>
      </tr>
      <tr id="dd2">
        <td >2</td>
        <td ><input type="checkbox" name="modtype3" value="value2" />
          <label>value2</label></td>
      </tr>
      <tr id="dd3">
        <td >3</td>
        <td ><input type="checkbox" name="modtype4" value="value3" />
          <label>value3</label></td>
      </tr>
      <tr id="dd4">
        <td >4</td>
        <td ><input type="checkbox" name="modtype5" value="value4" />
          <label>value4</label></td>
      </tr>
      <tr id="dd5">
        <td >5</td>
        <td ><input type="checkbox" name="modtype" value="value5" />
          <label>value5</label></td>
      </tr>
    </table>
    
    
    <br>
    <input type="button" name="onclick" id="onclick" value="Compare">
    <br>
    </form>
    
    <form><label></label><label></label>
      <table width="953" border="1">
      <tr id="dd1">
        <td width="829" >1</td>
        <td width="108" ><input type="checkbox" name="modtype2" value="value1" />
          <label>value1</label></td>
      </tr>
      <tr id="dd2">
        <td >2</td>
        <td ><input type="checkbox" name="modtype3" value="value2" />
          <label>value2</label></td>
      </tr>
      <tr id="dd3">
        <td >3</td>
        <td ><input type="checkbox" name="modtype4" value="value3" />
          <label>value3</label></td>
      </tr>
      <tr id="dd4">
        <td >4</td>
        <td ><input type="checkbox" name="modtype5" value="value4" />
          <label>value4</label></td>
      </tr>
      <tr id="dd5">
        <td >5</td>
        <td ><input type="checkbox" name="modtype" value="value5" />
          <label>value5</label></td>
      </tr>
    </table>
    
    
    <br>
    <input type="button" name="onclick" id="onclick" value="Compare">
    <br>
    </form>
    
    
    
    </body>
    </html>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I just answered this here:

    http://www.dynamicdrive.com/forums/s...134#post146134

    Please post only one post per question.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •