8 April 2011

how to implement two submit using one form in html

If you have amazing form but you want  2 (or more) submission with different action ..then you thinking... that is a problem,because you define action in form,so a. what you should do ?



  • First create you outstanding form 
<form method="POST" name="diary" action="save.html">
<!-- (...) your marvelous form -->
</form>
  • SecondlyAdd normal submit button, but add onclick   with line that will set action depend on submission 
<input type="submit" value="Save" onclick="diary.action='save.html'; return true;">   

  • For each next submit only what you need to change is  action (onclick="diary.action=nameofaction;return true;" for submit button (and name that will be display and other unique setting for you submit button)
 <input type="submit" value="Load" onclick="diary.action='load.html'; return true;">   

 draft example:

<form method="POST" name="diary" action="save.html">
<!-- put all form rubbish stuff .... like this 3 lines below. -->
Title <input type="text" id="newseditor"/><br/>
Note<input type="textarea" id="newseditor"/><br/>
Is is true story<input type="checkbox" id="newseditor"/><br/>

 <!-- here is important place when you set multiple submit stuff with diffrent actions -->
<input type="submit" value="Save" onclick="diary.action='save.html'; return true;">
<input type="submit" value="Load" onclick="diary.action='load.html'; return true;">
</form>

No comments:

Post a Comment