IIS ASP - Populate Dynamic dropdown box

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > February 2007 > Populate Dynamic dropdown box





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Populate Dynamic dropdown box
Simon Gare

2007-02-26, 7:16 pm

Hi,

have form on asp page that recalls data from the recordset and populates all
the fields except the dynamic dropdown box that doesn't, just shows default
value. How do I make it populate based on the entry in the db?

Regards
Simon


--
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk


Bob Barrows [MVP]

2007-02-26, 7:16 pm

Simon Gare wrote:
> Hi,
>
> have form on asp page that recalls data from the recordset and
> populates all the fields except the dynamic dropdown box that
> doesn't, just shows default value. How do I make it populate based on
> the entry in the db?
>


As you write each option string to Response, compare the string you are
writing as the option's value to the data in the recordset. If They are
the same, write "selected" to response before closing the option's tag.
Otherwise, don't write "selected".

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Simon Gare

2007-02-26, 7:16 pm

Thanks Bob,

Got it

<select name="Access_level" id="select2">
<option value"">Select access level</option>
<option value="1" <% response.write "selected"
%>>Driver</option>
<option value="2" <% response.write "selected" %>>Operator /
Controller</option>
<option value="3" <% response.write "selected"
%>>Administrator</option>
</select>

Worked perfectly trying too hard again I was Dim this and Dim that couldnt
get my head around it.

Simon

..
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OhPbG7eWHHA.192@TK2MSFTNGP04.phx.gbl...
> Simon Gare wrote:
>
> As you write each option string to Response, compare the string you are
> writing as the option's value to the data in the recordset. If They are
> the same, write "selected" to response before closing the option's tag.
> Otherwise, don't write "selected".
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



Bob Barrows [MVP]

2007-02-26, 7:16 pm

Simon Gare wrote:
> Thanks Bob,
>
> Got it
>
> <select name="Access_level" id="select2">
> <option value"">Select access level</option>
> <option value="1" <% response.write "selected"
> %>>Driver</option>
> <option value="2" <% response.write "selected"
> %>>Operator / Controller</option>
> <option value="3" <% response.write "selected"
> %>>Administrator</option>
> </select>
>
> Worked perfectly trying too hard again I was Dim this and Dim that
> couldnt get my head around it.
>
> Simon
>


That works?? If you say so ...
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Simon Gare

2007-02-26, 7:16 pm

Bob,

have a problem, the way I did it hasn't worked should I be doing something
like,

<% if ACCESS_LEVEL(0) = true then response.write "selected" %>

??

Simon


"Simon Gare" <simon@simongare.com> wrote in message
news:%23pSWcAfWHHA.4964@TK2MSFTNGP06.phx.gbl...
> Thanks Bob,
>
> Got it
>
> <select name="Access_level" id="select2">
> <option value"">Select access level</option>
> <option value="1" <% response.write "selected"
> %>>Driver</option>
> <option value="2" <% response.write "selected" %>>Operator /
> Controller</option>
> <option value="3" <% response.write "selected"
> %>>Administrator</option>
> </select>
>
> Worked perfectly trying too hard again I was Dim this and Dim that couldnt
> get my head around it.
>
> Simon
>
> .
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
> news:OhPbG7eWHHA.192@TK2MSFTNGP04.phx.gbl...
>
>



Evertjan.

2007-02-26, 7:16 pm

Simon Gare wrote on 26 feb 2007 in
microsoft.public.inetserver.asp.general:

> <select name="Access_level" id="select2">
> <option value"">Select access level</option>
> <option value="1" <% response.write "selected"
> %>>Driver</option>
> <option value="2" <% response.write "selected"
> %>>Operator /
> Controller</option>
> <option value="3" <% response.write "selected"
> %>>Administrator</option>
> </select>
>


I don't think this is very useful as it just places a selected in each
option, so probably the top one will have an effect.


<%
s = ~numeric result from database~
%>

<select name="Access_level" id="select2">
<option value="">
Select access level</option>
<option value="1" <% if s=1 then response.write "selected" %>>
Driver</option>
<option value="2" <% if s=2 then response.write "selected" %>>
Operator / Controller</option>
<option value="3" <% if s=3 then response.write "selected" %>>
Administrator</option>
</select>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Bob Barrows [MVP]

2007-02-26, 7:16 pm

Simon Gare wrote:
> Bob,
>
> have a problem, the way I did it hasn't worked should I be doing
> something like,
>
> <% if ACCESS_LEVEL(0) = true then response.write "selected" %>
>
> ??
>

Yes, that's more like it. Have you tried it? Does it work? If not, write
the value of ACCESS_LEVEL(0) to Response and show us what it is.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Simon Gare

2007-02-26, 7:16 pm

it did Bob thanks

<option value="00:10" <% if (AirportStation.Fields.Item("LeadTime").Value) =
("00:10:00") then response.write "selected" %>>10 Mins</option>

Regards
Simon

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:eBJf8bfWHHA.996@TK2MSFTNGP02.phx.gbl...
> Simon Gare wrote:
> Yes, that's more like it. Have you tried it? Does it work? If not, write
> the value of ACCESS_LEVEL(0) to Response and show us what it is.
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com