SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Submit to another page

    Hello

    I have a page1.jsp with a form and different buttons. When the user clicks the button "MAIL" i open a popup that has 2 fields for the email address. When the user submits the popup form i want to return these values to page1.jsp

    How can i do it with Javascript?

    Thanks
    dReAm

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Give the main window a name. Add a target="mainwindowname" attribute to your <form> tag.

    Not tested - just a thought.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by siteguru View Post
    Give the main window a name. Add a target="mainwindowname" attribute to your <form> tag.

    Not tested - just a thought.
    what do u mean give the main window a name ?? How will the popup windows know that it has to submit the values to the main window (page1.jsp)
    dReAm

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my main page
    Code:
    ............... jsp code ...............
    <HEAD><TITLE>
    </TITLE></HEAD>
    <script language='JavaScript' src='/jsp/IForm06a.js'>
    <BODY text=#000000 link=#0000ff bgColor=#ffffff onLoad="chiudi('<%=ritorno%>');f_onload();" onUnload='javascript:ripristinatop()' >
    <form NAME='FormS4' ACTION='../jsp/IForm06p.jsp' METHOD='post'>
    ............... html code ...............
    
    <B>
    Invia il modulo tramite Form Mail Service
    <P>
    </P>
    </B>
    Destinatario:
    <P>
    </P>
    </FONT>
    <B>
    
    <textarea rows='4' cols='90' id='txtAEMAIL_TO' name='txtAEMAIL_TO' alt='0'
    style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"
     onfocus='javascript:help(this.title)'><%=formBuilder.getFieldValue(modulo, "txtAEMAIL_TO", xmlDati)%>
    </textarea>
    </B>
    <FONT style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial'">
    <P>
    </P>
    MIttente:
    <P>
    </P>
    </FONT>
    <B>
    
    <textarea rows='4' cols='90' id='txtAEMAIL_FROM' name='txtAEMAIL_FROM' alt='0'
    style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"
     onfocus='javascript:help(this.title)'><%=formBuilder.getFieldValue(modulo, "txtAEMAIL_FROM", xmlDati)%>
    </textarea>
    </B>
    <FONT style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial'">
    <P>
    </P>
    Per Conoscenza:
    <P>
    </P>
    </FONT>
    <B>
    
    <textarea rows='4' cols='90' id='txtAEMAIL_CC' name='txtAEMAIL_CC' alt='0'
    style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"
     onfocus='javascript:help(this.title)'><%=formBuilder.getFieldValue(modulo, "txtAEMAIL_CC", xmlDati)%>
    </textarea>
    </B><br>
    <TABLE><TR><TD><input style='display:inline' type='button' value='precedente' onclick='javascript:return cmdBack()'></TD><TD><input style='display:inline' type='button' value='visualizza' onclick='javascript:return cmdSubmit()'></TD></TR></TABLE>
    <input type='button' value=' mail ' onclick='javascript:return cmdInvioMail()'>
    <FORM NAME="hiddenForm">
    <SCRIPT LANGUAGE="JavaScript"><!--
    document.write('<P>Data passed = ' + location.search);
    //--></SCRIPT>
    </FORM>
    ............... jsp code ...............
    my popup page
    Code:
    <html>
    <head>
    <title>jForm - Form Mail Service</title>
    <script language="JavaScript">
    
    function copyForm() {
    	alert("iN");
        opener.top.hiddenFrame.document.FormS4.txtAEMAIL_TO.value = document.popupForm.TXTMAIL_TO.value;
        opener.top.hiddenFrame.document.FormS4.txtAEMAIL_FROM.value = document.popupForm.TXTMAIL_FROM.value;
        opener.top.hiddenFrame.document.hiddenForm.submit();
        window.close();
        return false;
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF" bgproperties="fixed">
    	<FORM NAME="popupForm" onSubmit="return copyForm()">
    <table width="566" border="0" cellpadding="4" cellspacing="0">
      <tr>
        <td class="Menu1Title">Digitare e-mail destinatari/o:</td>
        <td><input name="TXTMAIL_TO" id="TXTMAIL_TO" value="" size="40" maxlength="100"></td>
        </tr>
      <tr>
        <td class="Menu1Title">Digitare e-mail mittente:</td>
        <td><input name="TXTMAIL_FROM" id="TXTMAIL_FROM" value="" size="40" maxlength="100"></td>
        </tr>
    </table>
    	    <table width="568">
      <tr>
        <INPUT TYPE="BUTTON" VALUE="Submit" onClick="copyForm()">
        
        <br>Digitare gli indirizzi e-mail dei destinatari separati da punto e virgola (;).</td>
        </tr>
    </table>
      </form>
    </body>
    </html>
    the only thing that happens is that i get the alert "IN"
    dReAm

  5. #5
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Main:
    Code:
    <script language='JavaScript' src='/jsp/IForm06a.js'>
    <script type="text/javascript">
    window.name = "main";
    </script>
    Popup:
    Code:
    <FORM NAME="popupForm" target="main" onSubmit="return copyForm()">
    (UNTESTED!!)
    Ian Anderson
    www.siteguru.co.uk

  6. #6
    SitePoint Zealot
    Join Date
    Sep 2004
    Location
    Milan, Italy
    Posts
    152
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It stops after the alert in the pop up. In the browser error console i get a message saysing

    Code:
    opener.top.hiddenFrame has no properties
    and it points to the line 17 which is
    Code:
    opener.top.hiddenFrame.document.FormS4.txtAEMAIL_TO.value = document.popupForm.TXTMAIL_TO.value;
    Any idea?

    Thanks
    dReAm

  7. #7
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Sorry - I haven't looked at your code. Have you tried my suggestion?
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

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