I need to have a form execute two scripts so that means two different actions from the same form. I've tried some javascripts that use form.submit() from an onClick action on a submit button. But one of the two actions is an ASPX script that goes to Dynamics CRM. Any suggestions?
Maybe the form could have only one action that would forward the request to the second action, once it has finished its operation
Using jQuery, you could interrupt the form submission and do your own thing before it actually submit.
Example using jquery's ajax post:
$( 'form' ).submit( function(){
$.post(
'action2.php', // url of php
{ // data to send
data1:'bob',
data2:'denver'
}
)
})
Could you not have an intermediate script, that dispatches the info. to the second script? For example (submit.php
):
<?php
if (isset($_POST['action_1'])) {
// send to script 1
}
else if ($_POST['action_2']) {
// send to script 2
}
else {
// friendly error handling here
}
?>
And your form's mark-up...
<form action="submit.php" method="post">
<input type="submit" name="action_1" value="Action 1" />
<input type="submit" name="action_2" value="Action 2" />
</form>