Results 1 to 4 of 4

Thread: Javascript problem

  1. #1

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Javascript problem

    I am submitting a form from one frame to another,

    <form method="post" action="request.asp" target="main" name="form1">

    <td width="80%" height="40" valign="middle" bgcolor="#CCCCCC" class="tdbutton">
    <div align="center">
    <input type="hidden" name="F_NAME" value="<%response.write V_NAME %>">
    <input type="hidden" name="F_ACCESS" value="<%response.write V_ACCESS %>">
    <input type="hidden" name="F_PROFILE" value="<%response.write V_PROFILE %>">
    <a href="javascript:frames[0].document.form1.submit();">Request report</a> </div></td>
    </form>

    but get message form 1 is nul or not an object. does anyonme knwo why it cant fnd the form, i think it is looking for the form in my other frame as if i change te form name in the url to a form one my main frame it will submit ok.

    please help

  2. #2
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Well you don't really need the frames[] stuff in there, just use document.form1.submit() But also you aren't catering for people without JavaScript, so what you should do is this:

    Code:
    <script type="text/javascript"><!--
      document.write('<a href="#" onclick="document.form1.submit();">Request report<\/a>');
    //--></script>
    <noscript><div><input type="submit"></div></noscript>
    That way people with JS will see the link, and people without will just get a standard submit button, keeping everyone happy

  3. #3
    Addicted Member
    Join Date
    Jul 2002
    Posts
    234
    Also be aware that after IE4, microsoft (and netscape) changed the frames permission model, so often times one cannot get or manipulate data across frames.

  4. #4
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    Oh sorry after reading that last post I think you're trying to submit a form in another frame, is that correct? If so then I'd use the frames array, but instead of using an integer, I'd use the name of the frame:

    Code:
    frames['frameName'].document.form1.submit();
    Or if you mean you want to have the current for sumbit, and show the results in another frame just give the form a target attribute:

    Code:
    <form action="page.php" target="frameName">...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width