Previous Example-|-Next Example-|-Return to Chapter Listing

Example 15.20:
Picking Your Destination

You can use the following selection box to pick which window you want to see, from ten options. When you click on the item, that window automatically opens (of course you could have a button that checks what you've selected and then opens the window, if you wish).

Note that this script uses the focus() method to bring the secondary window back again. If you are using a JavaScript 1.0 browser (Netscape Navigator 2 or an early beta of 3) this feature won't work.
This is the script we used: <SCRIPT LANGUAGE="JAVASCRIPT"> <!-- function Dest(form) { var sGo if (form.select1.selectedIndex == 0) sGo = "15-20a.htm"; if (form.select1.selectedIndex == 1) sGo = "15-20b.htm"; if (form.select1.selectedIndex == 2) sGo = "15-20c.htm"; if (form.select1.selectedIndex == 3) sGo = "15-20d.htm"; if (form.select1.selectedIndex == 4) sGo = "15-20e.htm"; if (form.select1.selectedIndex == 5) sGo = "15-20f.htm"; if (form.select1.selectedIndex == 6) sGo = "15-20g.htm"; if (form.select1.selectedIndex == 7) sGo = "15-20h.htm"; if (form.select1.selectedIndex == 8) sGo = "15-20i.htm"; if (form.select1.selectedIndex == 9) sGo = "15-20j.htm"; form.select1.blur() ; Win1=open(sGo,"Window1","width=400,height=200"); Win1.focus() } //--> </SCRIPT> Here are the buttons: <form> <select name="select1" size=4 onchange="Dest(this.form)"> <option>The White Room <option>The Red Room <option>The Green Room <option>The Purple Room <option>The Gray Room <option>The Brown Room <option>The Yellow Room <option>The Blue Room <option>The Crimson Room <option>The Olive Room </select> </form>
Previous Example-|-Next Example-|-Return to Chapter Listing