Persist Selection

J

John Kirkman

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
 
J

Jim Buyens

-----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.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.interlacken.com
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)
|/---------------------------------------------------
*----------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top