clicking button in a table


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: clicking button in a table

  1. #1
    Join Date
    Dec 2006
    Posts
    4

    clicking button in a table

    Hi,

    I want a javascript which will click on a button present in a table.

    Following is my HTML code

    <table id="myTable" >
    <tr>
    <td><input class="buttonStyle" TYPE="SUBMIT" VALUE="Save" onClick = "alert('Save')"</td>
    <td><input class="buttonStyle" TYPE="BUTTON" VALUE="Discard" onClick = "alert('Discard')"</td>
    </tr>
    </table>
    <br />
    <input type="button" onclick="showRow()" value="Show innerHTML ">

    Following JavaScript does not work -

    document.getElementById('myTable').rows[0].cell[1].click

    Can anybody help me.

    Thanks!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Why not assign IDs to the buttons? Then you could simply do this:

    document.getElementById('btnDiscard').click
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Dec 2006
    Posts
    4
    Thanks for the speedy reply.
    The problem is HTML code is not owned by me. So I do not have any control over it.
    Any other solution ???

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    OK, well there a couple of obvious problems: the <input> tags in the HTML are missing closing angle brackets, and in your JavaScript it should be cells, not cell. Finally, your code is clicking on the cell itself, not on the button inside of it. Try this:

    document.getElementById('myTable').rows[0].cells[1].childNodes[0].click();
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Dec 2006
    Posts
    4
    Thanks you!
    It is working with the above code.
    Regards

Similar Threads

  1. Database Design Help needed
    By Brian Pittman in forum Database
    Replies: 2
    Last Post: 04-29-2007, 09:23 AM
  2. button listener not working
    By DrunkinP in forum Java
    Replies: 0
    Last Post: 03-31-2005, 10:36 AM
  3. Replies: 4
    Last Post: 08-12-2002, 06:05 PM
  4. Replies: 1
    Last Post: 02-16-2002, 09:20 AM
  5. Multi-row calculations
    By Bob Hines in forum Database
    Replies: 7
    Last Post: 04-27-2000, 12:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center