Re: Specify default on drop-down based on DRW?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Augie Dawg (NO_SPAMaugiedawg_at_earthlink.net)
Date: 02/16/04


Date: Mon, 16 Feb 2004 18:54:11 GMT

Jim:

I did as you suggested, placing the (appropriately modified) script after
the SUBMIT button definition but before the </form> tag using the INSERT
HTML Web component, and nothing happened. I also placed the script after
the </form> tag, and that didn't work either, I'm still seeing the first
entry in the database column as opposed to the current value. Am I
misunderstanding your directions, or did I not clearly state my problem? In
case it's the latter, I'm thinking I need to be able to somehow modify the
drop-down list properties to include an entry that would show the currently
selected record first.

A.D.

"Jim Buyens" <news@interlacken.com> wrote in message
news:f79c01c3f263$2e8e7d00$a301280a@phx.gbl...
> >-----Original Message-----
> >I've created a page where information in a record can be
> >modified. In a table-resident form, I list the current
> >value, then a drop-down which is created by the DRW. The
> >problem I'm trying to overcome is that the value
> >that shows in the drop-down is the first one returned
> >from the database, not the current value. I'd rather not
> >have to force the user to respecify all values just to
> >change one. I know how to specify the current value as
> >an option when the drop-down list choices are static, but
> >can't figure a way to get what I need when the choices
> >are dynamically generated. Any ideas out
> >there?
>
> I don't believe there's a nice, easy fix for this.
>
> For an ugly fix, try putting this at the bottom of your
> form, where CategoryID is the name of the DRW-generated
> drop-down list.
>
> <script>
> for (i = 0;
> i < document.forms[0].CategoryID.options.length - 1;
> i++) {
> if (document.forms[0].CategoryID.options[i].value
> == "<%=request("CategoryID")%>"){
> document.forms[0].CategoryID.selectedIndex = i;
> break;
> }
> }
> </script>
>
> This is *much* easier to do in ASP, and trivial in ASP.NET.
>
> 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)
> |/---------------------------------------------------
> *----------------------------------------------------
>
>


Quantcast