...

View Full Version : using window instead of alert box



fip04
05-05-2004, 08:42 AM
Hi,
consider the following 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

glenngv
05-05-2004, 09:11 AM
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();

fip04
05-05-2004, 12:14 PM
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:


C:\My documents\abc.jpg
C:\abc.txt

i need the output to be of the form:

<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

glenngv
05-05-2004, 02:43 PM
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;";

fip04
05-06-2004, 05:44 AM
Hi glenngv,
the code is working perfectly. thank u very much for ur valuable time and three cheers to you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum