Is it possible to trigger onSubmit event of the form by calling it with
function submitEdit(){
document.getElementById("edit").submit();
};
THIS WAY IS NOT WORKING
Form:
echo "<form id='edit' onsubmit='validate(flag, typeFlag)' method='post' style='width: 100%;height:86%;'>";`
onSubmit event:
window.flag=false;
var typeFlag;
function validate(flag, typeFlag) {
if ( (flag==true) && (typeFlag==true) ){
document.getElementById("edit").setAttribute('target', '_self');
document.getElementById("edit").action ="date.php";
} else if ( (flag==true) && (typeFlag==false) ){
document.getElementById("edit").setAttribute('target', '_blank');
document.getElementById("edit").action ="date_PDF.php";
} else
alert("Select an aircraft");
}
Am I doing it right? I need to submit this form by clicking on a radio button.
echo '<td class="c3" style="color: #f79393">
<div class="radio">
<label><input type="radio" name="name_check" onclick="typeFlag=true; submitEdit();" class="c3" value="in" id="c3" '; if($flag) echo'checked'; echo '>in</label>
</div>
</td>';
Thank You!
This post is old, but I might as well leave a new working solution. It appears that requestSubmit()
does exactly what OP needed. MDN documentation
The updated function:
function submitEdit(){
document.getElementById("edit").requestSubmit();
};