...

View Full Version : quick question



helpmeplease11
12-02-2006, 07:00 AM
you know you have like a submit button on a page or whatnot, is there a way to make the button to be like auto clicked when the page is loaded?

Kor
12-02-2006, 07:18 AM
you know you have like a submit button on a page or whatnot, is there a way to make the button to be like auto clicked when the page is loaded?
No, but why do you need that?

brandonH
12-02-2006, 08:58 AM
yes, but it may not work for all browsers:

<input type=button onclick="alert();" id=but1>

<script type=text/javascript>
function clickIt(){
document.getElementById('but1').click();
}
window.onload=clickIt
</script>

Kor
12-02-2006, 09:22 AM
As far as I know, upon standars, a click() method does not initiate an event trigger. If (probably IE) a browser still allows that, my answer is still no. For me (and for other coders as well) if something works only for a single type of browser and if there is no equivalent for the others, that something does not exist ;)

brandonH
12-02-2006, 09:30 AM
very true. but it does exsist, if only for IE. lol
i would not reccomend using it on a website. only for local file use with IE.

but like you ask above, why do you need that?


back to helpmeplease11.
if it is a submit button, you can also call submit() for the form via script:

<form name=myform id=myform action=somepage.htm method=get>
<input type=text name=text1 value=something>
<input type=submit>
</form>

<script type=text/javascript>
document.getElementById('myform').submit()
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum