cross-frame submit works, but not reset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin McKinnon

    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(targe tform,action,pa ram)
    {
    switch(action) {
    case '':
    break;
    case 'submit':
    widget=document .getElementById (targetform);
    if (widget.onsubmi t()) {
    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='multip art/form-data' method='POST'
    onsubmit='retur n(true);'>
  • Vincent van Beveren

    #2
    Re: cross-frame submit works, but not reset

    This script, in which frame is it called?

    document.getEle mentByID will only return elements in the current frame.

    Maybe you need to do something like:
    parent.otherfra me.document.get ElementById(tar getform);

    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:
    [color=blue]
    > 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(targe tform,action,pa ram)
    > {
    > switch(action) {
    > case '':
    > break;
    > case 'submit':
    > widget=document .getElementById (targetform);
    > if (widget.onsubmi t()) {
    > 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='multip art/form-data' method='POST'
    > onsubmit='retur n(true);'>[/color]

    Comment

    • Richard Cornford

      #3
      Re: cross-frame submit works, but not reset

      Colin McKinnon wrote:
      <snip>[color=blue]
      > ... 'widget.reset is not a function'. ...[/color]
      <snip>

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

      Richard.


      Comment

      Working...