javascript submit form with submit or button... automatically

I have a form that can be sumbitted with a sumbit or button type.

I was using  a submit type.

The form was submitted automatically with:
<form name=myform action=action.html method=post>
</form>
<script>
document.myForm.submit();
</script>

Now I changed the sumbit button and put an image. With an onclick="sumbit();" When I click it goes well
but I need an equivalent of the script that automatically send the form

robrodpProgrammerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Tomarse111Commented:
I'm not sure if I understand the problem correctly; you need the page to submit when a user clicks your image? on when they press the return the key?

A bit more detail would be helpful :-)
0
hieloCommented:
>>With an onclick="sumbit();"
Well, if you did a copy and paste, the problem is you misspelled submit()

other than that, make sure NO element on the html page has name="submit" nor id="submit"
0
robrodpProgrammerAuthor Commented:
I want the form to be submitted as soon as it is loaded. No clicking anywhere
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

hieloCommented:

<form name="myform" id="myform" action="action.html" method="post">
...
</form>
<script>
window.onload=function(){
  document.myform.submit();
}
</script>

Open in new window

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
robrodpProgrammerAuthor Commented:
I know it works. The problem is the original form has an image with an onclick that submits the form. When it is received by tha action it recognizes it comes from an image with a name and an id etc. and does waht it is supposed to do.

If submitted (not from an image) it does not do what it is supposed to do
0
hieloCommented:
post your form
0
robrodpProgrammerAuthor Commented:
If I run the code as below it works...  action does it job

if I delete the onclick from the image and replace it with a submit or make it autosubmit (with a function like proposed above) id does not do what it is supposed to do.

As if the receiveing page (action) recognizes it was invoked by and image click and (perhaps its parameters)


<form name="MyForm" method="post" action="http://whateveraction.com/" id="MainForm"">
<input name="HomeSearch1$txtQue" type="text" maxlength="50" id="HomeSearch1_txtQue" tabindex="1" class="campo_busqueda" value="love"  />
<input name="HomeSearch1$txtDonde" type="text" maxlength="50" id="HomeSearch1_txtDonde" tabindex="2" class="campo_busqueda" value="texas" onkeypress="return clickButton(event,'HomeSearch1_btnBuscarimg')" />
<input type="image" name="HomeSearch1$btnBuscarimg" id="HomeSearch1_btnBuscarimg" src="uiResources/bot_buscar.gif"  border="0" /><span id="HomeSearch1_lblError" onclick="submit();")></span>&nbsp;

Open in new window

0
hieloCommented:
what about:
window.onload=function(){
clickButton(window.event,'HomeSearch1_btnBuscarimg');
}
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.