M
Mark Kolber
I did a little searching on this but couldn't find an answer...
On my website, I have a section of stories
(www.midlifeflight.com/stories) There are different stores on
different pages that are selectable via a selection list.
To avoid having to rewrite the list on each page, I moved it into a
..js file that produces it where called. Primary advantage is that when
adding new pages, there only one option list to update.
Here's the code:
//
function story_goto( menuform )
{
var baseurl = 'file:///D|/Webs/Midlife-DM1/Midlife-DM1/stories/' ;
// var baseurl = 'http://www.midlifeflight.com/stories/' ;
selecteditem = menuform.url.selectedIndex ;
newurl = menuform.url.options[ selecteditem ].value ;
if (newurl.length != 0) {
location.href = baseurl + newurl ;
}
}
// Create the form
document.writeln('<form action="storylist" method="get">' );
document.writeln('<select name="url"
onchange="story_goto(this.form)">' );
// Create the Options
document.writeln('<OPTION VALUE="index.htm">--Choose a story
--</OPTION>');
document.writeln('<OPTION VALUE="maui.htm#start_story">Maui');
document.writeln('<OPTION
VALUE="columbia_river.htm#start_story">Columbia River & Mt Hood');
document.writeln('<OPTION VALUE="comntn.htm#start_story">Flying the
Colorado Rockies');
document.writeln('<OPTION VALUE="oldfriend.htm#start_story">Visit To
An Old Friend');
document.writeln('<OPTION VALUE="socal.htm#start_story">SOCAL and
Catalina Island');
document.writeln('<OPTION VALUE="natchez.htm#start_story">Natchez,
MS');
document.writeln('<OPTION VALUE="alaska.htm#start_story">Alaskan
Adventure');
document.writeln('<OPTION VALUE="devyn.htm#start_story">Angel Flight:
So Much for So Little');
document.writeln('<OPTION VALUE="pagosa.htm#start_story">Pagosa
Springs, CO');
document.writeln('<OPTION VALUE="sfotour.htm#start_story">San
Francisco Bay Tour');
document.writeln('<OPTION VALUE="fear.htm#start_story">Fear of
Flying');
document.writeln('<OPTION VALUE="biggin.htm#start_story">English
Channel Crossing');
document.writeln('<OPTION VALUE="sts.htm#start_story">Sonoma Valley,
CA');
document.writeln('<OPTION VALUE="syf.htm#start_story">St Francis,
KS');
// Finish the form
document.writeln( '</select>' );
document.writeln( '</form>' );
//
Works great, except that on every page where rendered, the first
option -- Select a Page -- appears as the default. When I was writing
the lists individually for each page, I would make the option
reflecting the current page the SELECTED option. So, for example, if
you were viewing the "San Francisco Bay Tour" page "San Francisco Bay
Tour" would also be the SELECTED option in the list.
Is there a way to replicate this behavior while still retaining the
efficiency or having only one place to create most of the list?
Mark Kolber
Denver, Colorado
=======================
email? Remove ".no.spam"
On my website, I have a section of stories
(www.midlifeflight.com/stories) There are different stores on
different pages that are selectable via a selection list.
To avoid having to rewrite the list on each page, I moved it into a
..js file that produces it where called. Primary advantage is that when
adding new pages, there only one option list to update.
Here's the code:
//
function story_goto( menuform )
{
var baseurl = 'file:///D|/Webs/Midlife-DM1/Midlife-DM1/stories/' ;
// var baseurl = 'http://www.midlifeflight.com/stories/' ;
selecteditem = menuform.url.selectedIndex ;
newurl = menuform.url.options[ selecteditem ].value ;
if (newurl.length != 0) {
location.href = baseurl + newurl ;
}
}
// Create the form
document.writeln('<form action="storylist" method="get">' );
document.writeln('<select name="url"
onchange="story_goto(this.form)">' );
// Create the Options
document.writeln('<OPTION VALUE="index.htm">--Choose a story
--</OPTION>');
document.writeln('<OPTION VALUE="maui.htm#start_story">Maui');
document.writeln('<OPTION
VALUE="columbia_river.htm#start_story">Columbia River & Mt Hood');
document.writeln('<OPTION VALUE="comntn.htm#start_story">Flying the
Colorado Rockies');
document.writeln('<OPTION VALUE="oldfriend.htm#start_story">Visit To
An Old Friend');
document.writeln('<OPTION VALUE="socal.htm#start_story">SOCAL and
Catalina Island');
document.writeln('<OPTION VALUE="natchez.htm#start_story">Natchez,
MS');
document.writeln('<OPTION VALUE="alaska.htm#start_story">Alaskan
Adventure');
document.writeln('<OPTION VALUE="devyn.htm#start_story">Angel Flight:
So Much for So Little');
document.writeln('<OPTION VALUE="pagosa.htm#start_story">Pagosa
Springs, CO');
document.writeln('<OPTION VALUE="sfotour.htm#start_story">San
Francisco Bay Tour');
document.writeln('<OPTION VALUE="fear.htm#start_story">Fear of
Flying');
document.writeln('<OPTION VALUE="biggin.htm#start_story">English
Channel Crossing');
document.writeln('<OPTION VALUE="sts.htm#start_story">Sonoma Valley,
CA');
document.writeln('<OPTION VALUE="syf.htm#start_story">St Francis,
KS');
// Finish the form
document.writeln( '</select>' );
document.writeln( '</form>' );
//
Works great, except that on every page where rendered, the first
option -- Select a Page -- appears as the default. When I was writing
the lists individually for each page, I would make the option
reflecting the current page the SELECTED option. So, for example, if
you were viewing the "San Francisco Bay Tour" page "San Francisco Bay
Tour" would also be the SELECTED option in the list.
Is there a way to replicate this behavior while still retaining the
efficiency or having only one place to create most of the list?
Mark Kolber
Denver, Colorado
=======================
email? Remove ".no.spam"