468,780 Members | 2,212 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,780 developers. It's quick & easy.

cross-frame submit works, but not reset

Hi all,

I've got two frames, one with a form ('main') and one with some clickable
images ('tp'). The clickable images call a function in 'main' (code below)
which in turn calls the .submit() or .reset() methods of the form.

The submit call does what is expected. But the reset call throws an error in
Mozilla (1.2.1) 'widget.reset is not a function'. It doesn't work in
Konqueror (3.1.1) either (don't have an error message - it just don't
work). Clicking on a reset button within the form has the expected result.

Am I doing something stoopid?

TIA,

Colin
function tp_action(targetform,action,param)
{
switch(action) {
case '':
break;
case 'submit':
widget=document.getElementById(targetform);
if (widget.onsubmit()) {
widget.submit(); // this works !!!
}
break;
case 'reset':
widget=document.getElementById(targetform);
widget.reset(); // this doesn't !!!!!
// document.forms[targetform].reset(); // nor does this !!
// document.myform.reset(); // nor does this (myform is name/id of form)

break;
default:
alert('unknown action request ' + action);
break;
}
}
<snip>
<form name='myform' id='myform' enctype='multipart/form-data' method='POST'
onsubmit='return(true);'>
Jul 23 '05 #1
2 2064
This script, in which frame is it called?

document.getElementByID will only return elements in the current frame.

Maybe you need to do something like:
parent.otherframe.document.getElementById(targetfo rm);

But then again if that is the case then its weird that it works at all

You can also call the function from another frame so,

onClick='parent.otherframe.tp_action(...)';

good luck,
Vincent

Colin McKinnon wrote:
Hi all,

I've got two frames, one with a form ('main') and one with some clickable
images ('tp'). The clickable images call a function in 'main' (code below)
which in turn calls the .submit() or .reset() methods of the form.

The submit call does what is expected. But the reset call throws an error in
Mozilla (1.2.1) 'widget.reset is not a function'. It doesn't work in
Konqueror (3.1.1) either (don't have an error message - it just don't
work). Clicking on a reset button within the form has the expected result.

Am I doing something stoopid?

TIA,

Colin
function tp_action(targetform,action,param)
{
switch(action) {
case '':
break;
case 'submit':
widget=document.getElementById(targetform);
if (widget.onsubmit()) {
widget.submit(); // this works !!!
}
break;
case 'reset':
widget=document.getElementById(targetform);
widget.reset(); // this doesn't !!!!!
// document.forms[targetform].reset(); // nor does this !!
// document.myform.reset(); // nor does this (myform is name/id of form)

break;
default:
alert('unknown action request ' + action);
break;
}
}
<snip>
<form name='myform' id='myform' enctype='multipart/form-data' method='POST'
onsubmit='return(true);'>


Jul 23 '05 #2
Colin McKinnon wrote:
<snip>
... 'widget.reset is not a function'. ...

<snip>

<URL: http://www.jibbering.com/faq/faq_not....html#faComMis >

Richard.
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by rollasoc | last post: by
1 post views Thread by Rob Woodworth | last post: by
6 posts views Thread by Bart Van der Donck | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.