PDA

View Full Version : Drop-Down Document Viewer



alfredglenstein
11-30-2005, 09:29 PM
DD Script: Drop-Down Document Viewer
http://www.dynamicdrive.com/dynamicindex3/dropdownview.htm

I hope this doesn't qualify as trying to get several of the same script on one page. I want to modify a part of it to allow for seperate menus.

Right now the script only recognizes the form name "jumpy" and the select name "example".

Suppose I wanted the same Iframe to additionally respond to a "jumpy2" and "example2", or several "jumpy" and "example"s??

Seperately, instead of the > symbols, the example code has many of those replaced with: > so for beginners who know less than even me, they may run into problems if they copy and paste it.

I sincerely appreciate any help.

ddadmin
12-01-2005, 09:49 AM
That actually just requires a simple modification. First, replace function gone() inside the script with the modified version instead:



function gone(selectobj){
var selectedurl=selectobj.options[selectobj.selectedIndex].value
if (document.getElementById&&displaymode==0)
document.getElementById("external").src=selectedurl
else if (document.all&&displaymode==0)
document.all.external.src=selectedurl
else{
if (!window.win2||win2.closed)
win2=window.open(selectedurl)
//else if win2 already exists
else{
win2.location=selectedurl
win2.focus()
}
}
}


Then for your drop down menus, use this syntax instead:



<form>
<select name="menu1" size="1" onChange="gone(this)">
<!-- CHANGE THE BELOW URLS TO YOUR OWN-->
<option value="http://www.yahoo.com" selected>Yahoo.com</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.lycos.com">Lycos</option>
<option value="http://www.AltaVista.com">AltaVista</option>
</select>
<input type="button" name="test" value="Go!" onClick="gone(this.form.menu1)">

<select name="menu2" size="1" onChange="gone(this)">
<!-- CHANGE THE BELOW URLS TO YOUR OWN-->
<option value="http://www.cnn.com" selected>CNN.com</option>
<option value="http://news.bbc.co.uk">BBC News</option>
<option value="http://www.msnbc.com">MSNBC</option>
</select>
<input type="button" name="test" value="Go!" onClick="gone(this.form.menu2)">
</form>

This creates two menus, though can have as menus as you want.

alfredglenstein
12-01-2005, 03:43 PM
thanks!