cross-frame submit works, but not reset

C

Colin McKinnon

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);'>
 
V

Vincent van Beveren

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(targetform);

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top