#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0

    Question passing user entry from popup back to main form


    Hi, I have a form in which a textbox is filled using a pop-up page. This pop-up page has a selection of values created dynamically from an access table. I need to know how to get the values selected from the pop-up back to the main form. Can anyone guide me in the right direction, please.

    Many thanks,

    mtndew
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada - Egypt
    Posts
    60
    Rep Power
    12
    you could use the form Target paramemter

    in the popup

    <FORM name ="form_Name" Target = "main_PageName">

    .....

    </FORM>

    but that will cause the main page to refresh.

    To avoid refreshing

    if the pop up window is opened using java script from the main page

    use the .oDocument to have a reference back to the main document from the pop up

    example

    in the main page

    you open the pop up using something like this

    =============================
    var theWindow = window.open( "", "", "whateverparamemter", "").document;

    theWindow.open("text/html", "replace");
    theWindow.oDocument = this;

    theWindow.write("<HTML>the rest of the pop up page");
    =============================

    in side the pop up
    to access the popup page you use document.X
    to access the main page you use document.oDocument.X


    I have done this before and works perfect. If you have any trouble with it let me know.


    I hope this is of any help
    I hope this is of any help to anyone.

    Yassoor
    http://www.WebsitesCreation.ca
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    6
    Rep Power
    0
    Thanks, I was able to figure it out and I'll share it with you;

    First, on the form page I put in a function to open a new window(found this on the web and changed appropriately)

    <SCRIPT LANGUAGE="JavaScript">

    function newWindow(file,window) {
    msgWindow=open(file,window,'resizable=no,Toolbar=no, menubar=no, status=yes, scrollbars=yes, height=400, width=600, left=50, Top=50');
    if (msgWindow.opener == null) msgWindow.opener = self;
    }
    </script>

    Then created an text input element so I would have someplace to put the chosen value(s).

    <input name="TOE" type="text" value="Click Button to select" READONLY size="20" tabindex="5">

    And a button in which to open the pop-up page;

    <TD align="center" colspan="1" bgcolor="#D3D3D3"><input type="button" value="Type of Entry" onClick="newWindow('toe3.asp','window2')">
    </TD>

    Then, the pop-up page

    First, a function to update the main form page (found on the web and changed accordingly)

    <SCRIPT LANGUAGE="JavaScript">
    <!--

    function update() {
    var output = '';

    for (var i=0;i < document.forms[0].selectfield.options.length;i++) {
    if (document.forms[0].selectfield.options[i].selected) {
    output += document.forms[0].selectfield.options[i].value + ' ';
    }
    }

    opener.document.forms[0].TOE.value = output;
    window.close();
    }


    -->
    </SCRIPT>

    ADO Connection

    <%
    set rsTOE = Server.CreateObject("adodb.Recordset")
    %>

    Then, a table to hold a drop down select dynamically generated using vbscript and ASP;

    <form onSubmit="return false">

    <Table Border="0" Bordercolor="#000000" cellpadding="1" cellspacing="2" cols="4" width="55%">
    <TR>

    <TD align="left" colspan="1">
    <%

    sql="Select * From tblTOE Order By TOEID ASC"

    rsTOE.Open sql, con
    ' Loop through recordset and display results
    If Not rsTOE.EOF Then
    rsTOE.MoveFirst
    ' the form below calls this file only this time with an id in the QueryString
    %>


    <SELECT NAME="selectfield" size=10 MULTIPLE tabindex="5">

    <Option Value="" Selected></Option>
    <%
    ' Continue until we get to the end of the recordset.
    Do While Not rsTOE.EOF
    ' For each record we create a option tag and set it's value to the TOE ID
    ' The text we set to the TOE text
    %>

    <OPTION VALUE="<%= rsTOE.Fields("TOEID") %>"><%= rsTOE.Fields("TOE") %></OPTION>
    <%
    ' Get next record
    rsTOE.MoveNext
    Loop
    %>

    </SELECT>
    <%
    End If
    rsTOE.close
    Set rsTOE = Nothing

    %>
    </TD>
    <TD>
    <%
    Response.Write "<Center><Font Face='Lucida' Size='4' Color='#FFFFFF'>For Multiple Selections</Font></Center>"
    Response.Write "<Center><Font Face='Lucida' Size='4' Color='#FFFFFF'>press CTRL key, click on each</Font></Center>"
    Response.Write "<Center><Font Face='Lucida' Size='4' Color='#FFFFFF'>selection using left mouse button.</Font></Center>"
    %>
    </TD>
    </TR>
    </table>
    </body>
    </html>

    Thanks for your suggestion, I will try it out. There is always something new to learn in this business.

IMN logo majestic logo threadwatch logo seochat tools logo