Hi,
I not sure if I identified the problem correctly. I’m using Javascript to submit forms in a HTML file. In this particular case I have three of them all with different target urls.
Yet, when I run the function submitting one form another form is submitted. When I have an alert just before the submit command it submits the correct one…
Here’s the code (or at least the relevant parts of it) so you’ll better understand.
First the html part:
[CODE]
<form method=”post” action=”refer_to_repair_activity.php” name=”existing_repair_activity_form” id=”existing_repair_activity_form”>
<input type=”hidden” id=”existing_repair_activity_id” name=”id” value=””>
<input type=”hidden” id=”existing_repair_activity_cid” name=”cid” value=””>
</form>
<form method=”post” action=”general_car_details.php” name=”general_car_details_form” id=”general_car_details_form”>
<input type=”hidden” id=”general_car_details_id” name=”id” value=””>
</form>
<form method=”post” action=”refer_to_repair_activity.php” name=”add_new_repair_activity_form” id=”add_new_repair_activity_form”>
<input type=”hidden” id=”add_new_repair_activity_id” name=”id” value=””>
</form>
And here’s the Javascript function:
[CODE]
function submitExistingRepairActivity(rpID, carID) {
document.getElementById(“existing_repair_activity_id”).value = rpID;
document.getElementById(“existing_repair_activity_cid”).value = carID;
// alert(‘some annoying alert’);
document.forms[0].submit();
}
The function will be called when a link is clicked which will then provide the required parameters.
The form submitted is always general_car_details_form.
I would be happy for some ideas as to why this happens, especially because an alert just before submitting the form helps, setting breakpoints in the javascript debug mode helps as well, even though this is not really an option ?