[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

John Kirkman

4/23/2004 9:36:00 PM

Hello All,



I am using a dropdown list box to select criteria which in turns fills a
data results table on the same page. Is there some way to persist the
selection in the dropdown so that after the post back the dropdown will show
what was selected rather that the default selection?



Many thanks,



John






1 Answer

Jim Buyens

4/25/2004 4:59:00 AM

0

>-----Original Message-----
>Hello All,

Howdy.

>I am using a dropdown list box to select criteria which
>in turns fills a data results table on the same page. Is
>there some way to persist the selection in the dropdown
>so that after the post back the dropdown will show
>what was selected rather that the default selection?
>
>Many thanks,
>
>John

Add a script such as this to the bottom of your page.

<script>
for (i = 0;
i < document.forms[0].myfield.options.length - 1;
i++) {
if (document.forms[0].myfield.options[i].value
== "<%=request("myfield")%>"){
document.forms[0].myfield.selectedIndex = i;
break;
}
}
</script>

When you do this, be sure to change myfield (in four
places) to the name of your drop-down box. For drop-down
boxes that the DRW creates, this is usually the name of
the database field.

Alternatively, if the Database Results Wizard *isn't*
generating the drop-down box, you can add an ASP block to
each Option tag like this

<select name="myfield">
<option value="e"
<%if request("my field") = "e" then
response.write " selected"
end if%>
>East</option>

Jim Buyens
Microsoft FrontPage MVP
http://www.inter...
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------