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 5 of 5
  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using window instead of alert box

    Hi,
    consider the following code

    Code:
    var sel_1 = document.form1.sel;   
     var txt_1 = sel_1.options[sel_1.selectedIndex].text; 
     var opt_1 = sel_1.options[sel_1.selectedIndex].value;  
     var sel_2 = document.form1.sel2;    
     var txt_2 = sel_2.options[sel_2.selectedIndex].text;    
     var opt_2 = sel_2.options[sel_2.selectedIndex].value;  
     var theStr = "<choice>\n";   
     theStr += "<pic> " + opt_1 + " </pic>\n"; 
     theStr += "<tex> " + opt_2 + " </tex>\n";  
     theStr += "</choice>";  
     alert(theStr);
    In the above code, instead of using the alert box, i need to use a new window and the tags should be displayed in the new window. i went through some tutorials on windows in JS but was not of much help.
    can u help me out by mentioning some sort of pseudo-code?
    thanks in advance

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    var w = window.open('','mywin','width=500,height=500');
    w.document.write('<html><head><title>Choice</title></head><body><pre>'+theStr+'</pre></body></html>');
    w.document.close();
    w.focus();
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Feb 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi glenngv,
    ur code works well but it doesn't satisfy my requirement completely. in the new window, i get the ouptut in the form:

    Code:
    C:\My documents\abc.jpg
      C:\abc.txt
    i need the output to be of the form:
    Code:
    <choice>
     <pic>C:\My documents\abc.jpg</pic>
     <tex>C:\abc.txt</tex>
     </choice>
    ie i need the tags like '<choice>','<pic>' etc to also be displayed.
    thanks in advance

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    var theStr = "&lt;choice&gt;\n";
    theStr += "&lt;pic&gt; " + opt_1 + " &lt;/pic&gt;\n";
    theStr += "&lt;tex&gt; " + opt_2 + " &lt;/tex&gt;\n";
    theStr += "&lt;/choice&gt;";
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Feb 2004
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi glenngv,
    the code is working perfectly. thank u very much for ur valuable time and three cheers to you.


  •  

    Posting Permissions

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