Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Generating Pop-up Window

    First off, as usual, I would like to thank all you kind folks that have helped me in the past. My most recent project (Stellar Body Position Calculator) has turned into a "Stellar" success. Now, however, I am looking to add some new features.

    One of the features I would like to add is to allow the user to generate results for several Stellar Bodies. This, in and of itself, is not going to be a huge problem. What is going to be a problem, however, is displaying those results. My thought is to provide a "calculate" button that not only generates the results, but also stores them in an array. Again, not too much of a problem. What I would like to do with that array is render it in Table Format in a pop-up window so that the user can either print or save it in some fashion.

    What I have accomplished so far is;

    -Generating the array of values
    -Opening the pop-up window

    What I need now is a way to pass the information in the array to the pop-up window. I'm not sure if this is even possible using Javascript, but if it is, could one of you fine folks point me towards a tutorial that might help me figure out how to do this since I don't want to burden any of you with writing code that I need to learn how to write for myself?

    GW

  • #2
    Regular Coder fishluvr's Avatar
    Join Date
    Nov 2005
    Posts
    110
    Thanks
    1
    Thanked 12 Times in 12 Posts
    Try:

    window.opener.openerArrayName

    from the new window.

  • #3
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Thanks for the suggestion, fishluvr, but what I am really looking for is a tutorial on the subject rather than a quick answer. Since I am still in the midst of the learning curve when it comes to JScript, I am trying to understand what it is I am doing rather than simply cutting and pasting the stuff other people have done. I seem to remember a tutorial about this subject being located at Javascriptkit.com, but cant seem to find it now so I was hoping someone here might know where I could find one.

    GW

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    main page:
    Code:
    function doOpen(){
      var w = window.open("", "popup", "width=600, height=400, resizable=1"); //create a blank window
      //generate html tags
      var html = '<html><head><title>Popup</title></head><body>\n';
      html += '<table>';
      
      //loop through the array to store the content in "html" variable
    
      html += '</table></body></html>';
      w.document.write(html); //output html tags to popup window
      w.document.close(); //close the output stream
      w.focus(); //set focus to the popup window
    }

  • #5
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Once again I find myself thanking you Glenn. I did manage to find a tutorial on the subject, but it wasn't very clear. Coupled with your code, however, it now makes sense.

    GW


  • #6
    Regular Coder
    Join Date
    Nov 2004
    Location
    near the only active volcano in the continental US
    Posts
    409
    Thanks
    6
    Thanked 2 Times in 2 Posts

    A couple more quick questions for Glenn about Generating Pop-up Windows

    Actually, anyone can answer, but I figured I would direct this towards Glenn first since he was the one that supplied the coding base for what I am trying to accomplish.

    The scripting you laid out looks at though it will work just fine for what I am trying to accomplish, however, I was wondering if . .

    1: I can add a doctype to the html variable
    2: I can add CSS, Javascript and/or Meta info to the "head" portion of the html variable.

    From what I can see, I don't think it would cause a problem if I added these things in (mostly the doctype and CSS) but if there is a problem with adding those things, I figured I better ask before I pull my hair out wondering why it isn't working.

    Basicly I am thinking it would look something like this, but just want to be sure. . .

    Code:
    function displaydata() //opens new window and displays stored data in table format
    	{
    	var showdata=window.open("","popup","width=700 height=500, toolbar, scrollbars, menu, resizable")
    	var data='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"\n'
    	data+='"http://www.w3.org/TR/REC-html40/loose.dtd">\n'
    	data+='<html>\n'
    	data+='<head>\n'
    	data+='<title>Accumulated Data Results</title>'
    	data+='<style type="text/css">\n'
    	data+='<!--\n'
    	data+='.norm {\n'
    	data+='color: white;\n'
    	data+='font-style: normal;\n'
    	data+='font-weight: normal;\n'
    	data+='font-size: small;\n'
    	data+='font-family: Arial;\n'
    	data+='}\n'
    	data+='-->\n'
    	data+='</style>\n'
    	data+='</head>\n'
    .
    .
    .
    .
    And so on and so forth until I have filled the table using the loop you suggested and then closed out with the last </html> tag and what not. Now I realize that what I have above could all have been smushed together, but I did it this way for ease of readability and what not. Anyways, if there is a problem adding this stuff, is their any sort of work around or am I just going to have to set my fonts and what not in a long-hand form?

    GW

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    That's correct. You can add anything to it just like in any other web page. You can also link to an external CSS/Javascript so the page won't be that long and of course to make the CSS/Javascript reusable in all pages.


  •  

    Posting Permissions

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