Here is the scenario:
I have 2 buttons, one in a form with the type and name submit and the other is a link which submits the form with an onclick event.
Since my form already has a submit button named submit, the JavaScript function form.submit() is not being sent. Because I’m using a framework I cannot change the name of submit button.
I have tried to add the style display: none to the submit button but that didn’t help.
Any suggestions?
Code:
<form method="post" action="../../process_form.php">
submit button
<input type="submit" value="submit" class="button" id="label_forsubmit" name="submit">
link
<a class="standart_link" onclick="javascript: YAHOO.wsc.ExpensecontrolOperationsSubmit('a','0','b');" href="javascript:">cancel</a>
</form>
JavaScript part:
var btn = document.getElementById(btn_div);
var parentForm = YAHOO.util.Dom.getAncestorByTagName(btn_div, 'form' );
parentForm.submit.style.disabled = 'none';
parentForm.submit();
I’d recommend alerting the creators of the framework. Something this serious should be fixed at the source of the problem, and adjusting the name of an element should be a small change for them.
In the meantime, you could remove the form element during the click event, storing it in a temporary variable. Then, call
submitand finally add the button back in during theonsubmitevent.Something like this, for example:
And, changing your link markup to this:
As a side note, I’d recommend abstracting your JS code from your HTML markup entirely.