views:

22

answers:

2

How can I make a form with my own "submit" button & post the info to a php server side?

how can I get js to post it?

A: 

You can use the submit() method to submit forms via javascript:

document.form_name.submit();

Or:

document.getElementById('form_id').submit();

Or:

document.forms[0].submit(); // submit first form on page
document.forms[1].submit(); // submit second form on page

If you don't want to use a submit button and want to use a normal button, you just need to put any of the above code in onclick event of that button.

Sarfraz
Thanks, the second worked.the first didn't... I got error on the page. By "form_name" do you mean it's ID or the "name" attribute?
Gal Miller
@Gal Miller: It meant name of the form :)
Sarfraz
A: 
<form id=myForm action=process.php>

<input name=text>

<INPUT TYPE="image" SRC="images/submit.gif">

</form>

To submit

document.getElementById('myForm').submit();
Byron Whitlock