Retain a visitor-specified value in a drop down list
Here's a tip that Jim Buyens * , a FrontPage MVP, contributed some time ago for retaining a visitor-specified value in a drop down list. If you're working with databases in FrontPage, the Database Results Wizard is probably what you use most, if not every, time you want to show database results on a Web page. When you use a drop-down list to display values from a database, you have probably noticed that after you submit the form, the selection in the drop-down list referts to the first item in the list. Jim's tip shows you how to make the drop-down list display the value that the visitor specified.
Switch to Code view and add a script such as the following just before the end of your form (that is, just before the </form> tag.)
<script>
for (i = 0; i < document.forms[0].CategoryID.options.length; i++)
{
if (document.forms[0].CategoryID.options[i].value == "<%=request.form("CategoryID")%>")
{
document.forms[0].CategoryID.selectedIndex = i;
break;
}
}
</script>
This sample code assumes that the name of the drop-down list box is CategoryID. To make the script work with your list box, change all four occurrences of the name CategoryID to the name of your list box. This will be the name you specify under Submit Values From This Field option on page four of the wizard.
* Jim Buyens is the author of ten computer books, including most recently Microsoft Office FrontPage 2003 Inside Out, from Microsoft Press, ISBN 0-7356-1510-1.
Comments
- Anonymous
July 21, 2004
This was EXACTLY the script I was looking for - followed the simple rules, but recieved a server error page. - Anonymous
July 28, 2004
The comment has been removed - Anonymous
July 19, 2005
The comment has been removed - Anonymous
July 22, 2005
The comment has been removed - Anonymous
July 23, 2005
A heap of wheat, says the Song of Songs
but I've never seen wheat in a pile :)
did you like it? - Anonymous
July 24, 2005
Nice one, but what about der weg ? anywya, congrats from me. - Anonymous
March 13, 2006
I keep getting this ")" Line4 do you wish to debug?
Can anyone say what im doing wrong? Using frontpage2003 - Anonymous
March 13, 2006
good one,its working - Anonymous
March 15, 2006
You have excellent and very informative site. - Anonymous
March 17, 2006
Great information for us users. Keep up. - Anonymous
March 17, 2006
You have very curious information site. - Anonymous
April 18, 2006
Hello and congratulations on your very nice web site - Anonymous
April 25, 2006
yours website is very good made with nice color layout - Anonymous
May 15, 2006
you got very nice site design and please get more updates - Anonymous
June 22, 2006
http://www.ringtones-dir.com/get/">http://www.ringtones-dir.com/get/ ringtones site. [URL=http://www.ringtones-dir.com]ringtones download[/URL]: Best free samsung ringtones, Cingular ringtones and more, Ringtones for free. [url=http://www.ringtones-dir.com]samsung ringtones[/url] From website . - Anonymous
June 22, 2006
http://www.ringtones-dir.com/get/ ringtones site. Best free samsung ringtones, Cingular ringtones and more, Ringtones for free. From website . - Anonymous
July 05, 2006
PingBack from http://kollect.wordpress.com/2006/07/05/links-for-2006-07-05/ - Anonymous
August 22, 2006
thanks it help me alot... - Anonymous
September 06, 2006
Very many thanks for a good work. Nice and useful. Like it! - Anonymous
September 19, 2006
Please, follow this link:
[url=http://trazodone.dostweb.com/ trazodone.html]trazodone[/url] [url=http://trazodone.dostweb.com/ trazodone_side_effects.html]trazodone side effects[/url] [url=http://trazodone.dostweb.com/ trazodone_hcl.html]trazodone hcl[/url] [url=http://trazodone.dostweb.com/ trazodone_weight_gain.html]trazodone weight_gain[/url] - Anonymous
September 20, 2006
Look this:
[URL=http://flexeril.darkbb.com]flexeril[/URL]
[URL=http://trazodone.darkbb.com]trazodone[/URL]
[URL=http://lisinopril.darkbb.com]lisinopril[/URL] - Anonymous
September 23, 2006
Tabblets! No prescription!
September DISCOUNTS!!!
http://avandia.darkbb.com
http://fluoxetine.darkbb.com
http://metformin.darkbb.com
http://lisinopril.zikforum.com
http://metoprolol.darkbb.com
http://zocor.darkbb.com - Anonymous
September 28, 2006
The comment has been removed