Hey I am very new to Web Programming. I have been learning PHP from the past few days and I am stuck at one thing.
I have a form tag in my code which has two submit
One way is to use Javascript to switch the form's action depending on which control has been clicked. The following example uses the jQuery library:
$(document).ready(function() {
$("#theForm input").click(function(e) {
e.preventDefault();
if(e.target.id == 'first') {
$("#theForm").attr("action", "somePage.php");
} else {
$("#theForm").attr("action", "anotherPage.php");
}
alert($("#theForm").attr("action"));
$("#theForm").submit();
});
});
Demo here: http://jsfiddle.net/CMEqC/2/