-
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!
-
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!
-
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 ???
-
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!
-
Thanks you!
It is working with the above code.
Regards
Similar Threads
-
By Brian Pittman in forum Database
Replies: 2
Last Post: 04-29-2007, 08:23 AM
-
By DrunkinP in forum Java
Replies: 0
Last Post: 03-31-2005, 09:36 AM
-
By Asher in forum ASP.NET
Replies: 4
Last Post: 08-12-2002, 05:05 PM
-
By sander in forum ASP.NET
Replies: 1
Last Post: 02-16-2002, 08:20 AM
-
By Bob Hines in forum Database
Replies: 7
Last Post: 04-27-2000, 11:14 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks