Reputation:
part of my HTML code:
<form method="post" id="form">
<input type="number" min="0" max="20" id="experience" required name="experience"title="experience" class="formfield" />
<input type="image" id="registersubmit4" name="registersubmit4" src="images/arrow-right.png" title="next"/>
</form>
I want to submit form when user clicks on next and after submitting, then move to the next page.
<input type="image">
works well for submitting but after submitting i want to move to the next page..
I used javascript for onclick() event as follows:
<input type="image" onclick=form.submit(); "location='next.html'">
this does not work. Please help...Thanks in advance.
Upvotes: 0
Views: 14974
Reputation: 1
I used this to solve my problem.
jQuery(window).attr("location", "your page or external link goes here");
Upvotes: 0
Reputation: 2046
Take a look at jQuery.post. You could try doing something like this.
<script>
// Attach a submit handler to the form
$( "#form" ).submit(function( event ) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var $form = $( this ),
exp = $form.find( "input[name='experience']" ).val(),
url = $form.attr( "action" );
// Send the data using post
var posting = $.post({
url: url,
data: { experience: exp } );
success: function( data ) {
window.location='next.html';
}
});
});
</script>
Upvotes: -2
Reputation: 114377
This is usually done by specifying an action on the form:
<form method="post" action="newpage.html" id="form">
...but if the page processing your form is different than the page you want to go to, you'd use a server-side redirect. How this works will depend on the server-side language you are using.
Upvotes: 7