SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jumping Between Windows

    HELP!
    I've been working on a small e-commerce site with the Access DB and ASP. I have one variable to get from a form that I open in a separate window and bring back to the current form in the current window. I would like to keep the sections all in this current form and not break it into separate forms. Can anybody tell me how to bring data back to the open form?

    Thanks.

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    JavaScript, you'll probably get a better response in teh Client Side Scripting forum.

    I'll get this moved for you
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    SitePoint Member doggi's Avatar
    Join Date
    Oct 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See the following example. Use the 'opener' object to get to your initial window.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <TITLE></TITLE>
    
    <script language="javascript">
    <!--
    function popup()
    {
    	var win = window.open('','','toolbar=yes,scrollbars=yes,width=200,height=300')
    	win.document.write('<html><body><input type="text" name="intext" id="intext"><br>');
    	win.document.write('<a href="javascript:opener.document.forms[0].mytext.value=intext.value;this.close()">close</a>');
    	win.document.write('</body></html>');
    }
    
    
    //-->
    </script>
    
    
    </HEAD>
    
    <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
    
    <form name="myform" id="myform">
    <input type="text" id="mytext" name="mytext" onclick="javascript:popup();">
    
    
    </form>
    
    
    </BODY>
    </HTML>

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I will give this a try.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried your code and could not get it to work. This is really driving me crazy. Any more help?

    Thanks

  6. #6
    SitePoint Member doggi's Avatar
    Join Date
    Oct 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you be more specific... I tried the code and it works with ie5+ Be aware that this forum added an extra space between java and script in the code.

  7. #7
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks for writing back Doggi.

    I've been working on this and got it all to work except:

    win.document.write('<a href="java scriptpener.document.forms[0].mytext.value=intext.value;this.close()">close</a>');

    I am actually coding this into the remote window to put the value into the opener window. I had too much code in the window to switch. so my code really is:

    opener.document.update.FormNum.value= FeeNumber.value;

    to accomplish this. If I replace the reference on the right with a string it works. The string value comes into the opener input element and the remote window closes. I just can't understand why the reference to the radio input name (FeeNumber).value pair doesn't work (return a value). AUUGGHH!

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doggi,

    I just read this at a site called "JavaScript Weenie"

    If you want to transfer values between windows, you're asking for trouble. The reason is that you're entering into Document Object Model (DOM) territory, and the Netscape and Explorer DOMs are quite different. It's not too hard to make the transfer work in just one type of browser, but doing it for both main browsers requires many lines of cross-browser JavaScript. In fact the cross-browser version is so difficult that it's rarely done - we've found no reference to it on the Internet. You'll almost certainly have to parse the browser and supply different code for the two main types.

    Maybe I should look at another way to accomplish this task such as writing to a temporary database table?

    Thanks

  9. #9
    This is all Mumbo Jumbo Amit's Avatar
    Join Date
    Oct 2001
    Location
    New Delhi, India
    Posts
    277
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try this

    Code:
    opener.document.update.FormNum.value=document.formname.FeeNumber.value;
    instead of

    Code:
    opener.document.update.FormNum.value= FeeNumber.value;
    if this doesn't work try figuring out if you can access the value of FeeNumber.value

    As a suggestion add the following line in your code just to check whether you are even getting the vaue ...
    Code:
    document.title = document.formname.FeeNumber.value;
    You can remove the line once the code works ..
    Note: formname is name of your form in the PopUp Window.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Amit, thanks for the suggestion. I did try that and still could not get it to work. I have resorted to checking the radio buttons individually and using the array number to send back which choice number was selected. I am also looking at cookies and session level variables in ASP.

  11. #11
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HELP! This is driving me crazy!!
    What I'm trying to do is for the user to press a button(called choose order form) to jump out to another window thru JavaScript have the user make an enty by pressing a radio button (no submit), close the remote window, bring the user back to the original window form and print a result from a database (based on the data from the remote window) underneath the button (called choose order form).

    Below is the jumping control structure I'm trying to make work


    <%
    Dim Cook1, FeeNum, state, objRSfee, strSQLfee, Fee, FormName
    call getname
    call doit
    %>

    <%
    sub getname
    response.write "<script language='javaScript'>"
    response.write "var win=window.open('OrderFeeSchedule2001.html','orderfees','scrollbars=yes,toolbars=yes,width=616,height=300');"
    response.write "</script>"
    end sub
    %>

    <%
    sub doit
    'Dim Cook1, FeeNum, state
    Cook1 = request.cookies
    FeeNum = Left(cook1,2)
    'Dim objRSfee, strSQLfee, Fee, FormName
    strSQLfee = "SELECT * FROM fees WHERE form_number Like '" & FeeNum &"'"
    set objRSfee = Server.CreateObject("ADODB.Recordset")
    objRSfee.Open strSQLfee,objConn,adOpenStatic,adLockReadOnly, adCmdText
    If objRSfee.EOF Then
    Fee = ""
    FormName = ""
    Else
    Fee = objRSfee("form_cost")
    FormName = objRSfee("form_name")
    End If
    end sub
    %>


    <%Response.Write "&nbsp;&nbsp;"&FormName%>
    </td>


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
  •