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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting a form with javscript

Status
Not open for further replies.
Aug 23, 2004
174
US
When submitting a form using document.myform.submit, how is the form submitted? I am validating my form using PHP but I'm not getting anything in the $_POST array.

Any ideas?
 
Hi

The [tt]form[/tt] is always submitted with the method specified in the [tt]method[/tt] attribute. The difference is that if no [tt]submit[/tt] or [tt]image[/tt] button activated the submitting, then no [tt]submit[/tt] or [tt]image[/tt] button information will be included. Otherwise the data is sent the same way and there is not way to detect any difference on the server side.

Show us your code.

Feherke.
 
I was trying to submit the form with an image using this code

Code:
<a href="#" onClick="document.myform.submit();"><img src=""></a>

I also tried

Code:
<img src="" onClick="document.myform.submit();">

I got it to work with

Code:
<input onClick="document.myTicketForm.submit();" type="image" src=""/>

I'm assuming the form won't submit unless I either fake clicking the submit button with javascript or use it as an <input>.
 
Hi

jkjoe said:
<input onClick="document.myTicketForm.submit();" type="image" src=""/>
That is pointless. The [tt]image[/tt] button's default behavior is to submit. No need for the JavaScript code.

But anyway, all three codes you posted are correct and works for me.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top