Yes I know frames suck, but for the web app I’m trying to build they are necessary for the design I’m aiming for. What I need to do is in one frame, submit a form and then clear a value in that form. What I’m discovering though is that when I run ‘this.form.submit()’ all code after it is skipped, is there any way to run code after running a .submit()?
Thanks guys
-IG
In both Mozilla Firefox and Internet Explorer, a runtime error in a script terminates the current script, so it’s not anything inherent in form.submit() that’s disallowing subsequent statements from being executed. Also, in both FF and IE, in the global context, “this” evaluates to the current window object, not to the document, which is what you would want if you wanted to access your form; this would explain the error, as you are trying to access a property (the submit method) of an undefined object (this.form).
The window object does contain the document property - however, you can simply refer to the document directly; using “this” would be unnecessary. You should probably be doing something like this:
document.forms.nameofyourform.submit();
// or...
document.getElementById("formid").submit();
I think both of these methods will work in both the FF and IE DOMs.
Also, note that in the document.forms collection, you can access your form both by its “id” attribute and its “name” attribute, whereas with getElementById you can use both only in Internet Explorer - in Firefox, only the correct “id” attribute will work. This is just a case of IE being wonky.
For example:
<form name="myform" id="myformid"></form>
<script type="text/javascript">
document.forms.myform.submit(); // works
document.forms.myformid.submit(); // works
document.getElementById("myformid").submit(); // also works
document.getElementById("myform").submit(); // works only in Internet
// Explorer, not in Firefox
</script>