how to simulate a button click on loading a page

Hi experts

I need a button to be programatically clicked when a page loads... how would I go about doing that?

I saw some things about a doClick function, but you'll have to talk to me like I'm 5 years old here.  I tried the doClick and it didn't work.

thanks

Julia
John AccountAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sajuksCommented:
//something like this ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function clickbtn()
{

document.getElementById('btn').click()
}
//-->
</SCRIPT>
</HEAD>

<BODY onload = "clickbtn()">
<FORM METHOD=POST >
<INPUT TYPE="text" NAME="txt">
<INPUT TYPE="reset" id= "breset">
<INPUT TYPE="button" id = "btn" value = "Click Me" onclick = "alert ('Hello World')">
</FORM>
</BODY>
</HTML>
0
sajuksCommented:
//another ex
<form action="http://search.google.com">
  <input type="hidden" name="x" value="1">
  <input type="submit" name="a" value="a">
  <input type="submit" name="b" value="b">


<input type=button value="simulate a click" onClick="document.forms[0].a.click();">
<input type=button value="simulate b click" onClick="document.forms[0].b.click();">
</form>
0
GwynforWebCommented:
I think only IE allows button .click()
0
GwynforWebCommented:
I was wrong the above works in all browsers. This seems simpler

<body onload="document.f1.i1.click(); ">

<form action="http://search.google.com" name="f1">
   <input name="i1" type="button" value="simulate a click" onClick="alert('hi from the button')"> </p>
</form>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
John AccountAuthor Commented:
Great GwynforWeb... that worked like a charm!

Julia
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.