anthony76
01-11-2004, 05:53 PM
I want to choose from a select box and open the pdf file - only if selectedIndex!=0 and also I want to open in new window. It works the first time. Then when I close the pdf file - the original html page takes long time to stabilize and the browser closes. I want to have the original page with the selectedIndex set to 0 and also I want to be able to reselect an item an open a new pdf file.
Thanks
Please see my code
<HTML>
<HEAD>
<TITLE>Testing select2</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function showfile(selector) {
if (selector[0].selected!=true) {
var result=selector.options[selector.selectedIndex].text;
var file=selector.options[selector.selectedIndex].value;
window.open().location.href=file;
selector.selectedIndex=0;
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD="POST" name="form1">
View orders that have been processed:
<SELECT NAME="appList" onChange="showfile(document.form1.appList)">
<OPTION SELECTED >Choose a category
<OPTION VALUE="erbooks.pdf">ERbooks
<OPTION VALUE="grbooks.pdf">GRbooks
<OPTION VALUE="etables.pdf">Etables
</SELECT>
<!--<INPUT TYPE="button" VALUE="View PDF File" onClick="showfile(appList)"> -->
</FORM>
</BODY>
</HTML>
Thanks
Please see my code
<HTML>
<HEAD>
<TITLE>Testing select2</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function showfile(selector) {
if (selector[0].selected!=true) {
var result=selector.options[selector.selectedIndex].text;
var file=selector.options[selector.selectedIndex].value;
window.open().location.href=file;
selector.selectedIndex=0;
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD="POST" name="form1">
View orders that have been processed:
<SELECT NAME="appList" onChange="showfile(document.form1.appList)">
<OPTION SELECTED >Choose a category
<OPTION VALUE="erbooks.pdf">ERbooks
<OPTION VALUE="grbooks.pdf">GRbooks
<OPTION VALUE="etables.pdf">Etables
</SELECT>
<!--<INPUT TYPE="button" VALUE="View PDF File" onClick="showfile(appList)"> -->
</FORM>
</BODY>
</HTML>