Reputation: 690
I have a problem on html button tag
This my html code
<form name="data_kirim" action="confirm_order.php" method="POST">
..... order input field ....
<button class="back_button" onclick="window.location.href='keranjang.php'">Back</button>
<input class="next_button" type="submit" name="submit_data_kirim" value="Next"/>
</form>
How to prevent button to submit this form, because button is using the href to back page,
Can someone help me?
Upvotes: 2
Views: 6178
Reputation: 947
you can call a function in javascript when click your button, redirect to your link and return false
or use preventDefault()
function with jquery
Upvotes: 2
Reputation: 372
<button class="back_button" onclick="window.location.href='keranjang.php'">Back</button>
<form name="data_kirim" action="confirm_order.php" method="POST">
<input class="next_button" type="submit" name="submit_data_kirim" value="Next"/>
</form>
A quick solution would be to move the back button outside the form since It's not using the form inputs anyway.
Upvotes: 2
Reputation: 5455
If you want to just make it link to another page and not submit the form then simply make it a normal button like so :
<a href="URL">Next</a>
This will not submit the form though.
Upvotes: 0