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!

programmatically executing "OnClick" for a button.

Status
Not open for further replies.

awolff01

Programmer
Jun 17, 2003
55
US
Hello,

I have a button on my page...Based on what parameters are passed to the URL query string I would like to simulate a user clicking on that button to trigger another event.

How can I do this programmtically?

Tia

Alex-
 
awolff,

document.formName.buttonName.click();

Should work for you. Like:

Code:
<html><head><title>TekTips</title>
<script>
function ck_value(val) {
if(val == 'Sherlock'){
 document.test.t_button.click(); }
}
</script></head><body>
<form name="test">
<input type="text" size="20" name="url_value" value="Sherlock" 
onBlur="ck_value(this.value)">
<input type="button" name="t_button" value="Test Button" 
onClick="alert('Programmatically Watson')">
</body></html>



Great Javascript Resource:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top