Forum Moderators: open
I have the following function which changes a forms action and it should then submit the form.
<script type="text/javascript">
function sub()
{
document.projects.action="form.php";
document.projects.submit();
}
</script>
The action is changed successfully but the form doesn't submit. I get the error generated from the submit() line:
Object doesn't support this property or method.
This code seems to work for others but not me.
Any help would be greatly appreciated.
Thanks
<form name="form1" action="" onSubmit="return false;">
<input type="text" name="wysiwyg">
<input type="submit" name="submitButton" onClick="someRoutine(this.form);" value="submit">
</form>
<form name="form2" action="" onSubmit="return false;">
<input type="text" name="wysiwyg">
<input type="submit" name="submitButton" onClick="someRoutine(this.form);" value="submit">
</form>
<script type="text/javascript">
function someRoutine(form) {
alert('form name is '+ form.name);
form.action = (form.name=='form1')?'script1.php':'script2.php';
form.submit();
}
</script>