|
|
|
|
|
| | |
|
Active Server Pages ASP programs help tutorial tutorials routine routines jobs listserve mailinglist bulletin board bulletin boards programming snippet snippets CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
How to Default an HTML List Box Selected Value? |
From: |
April |
Date: |
1/30/2001 9:08:24 PM |
IP: |
205.175.225.22 |
HELP!! I'm at wit's end with this. I have a SQL 7 back end DB with an asp front end. I'm trying to provide users with an HTML select box for editing data, but I want the box to default to whatever the current data value from the database is. The database recordset for the page is called "rsTypeData", and it contains a field called "Direct" which can only accept a value of "0" or "1". From the user's perspective, the value "0" translates to the word "Indirect" and the value "1" translates to "Direct".
Here's my code, which isn't working. The select box renders properly, giving the user a drop-down to select either "Direct" or "Indirect". The box also sends the correct value back to the database when I make a selection and submit the form. But the select box doesn't default to the correct selected item based on what the underlying data is when the page is first opened. It always just defaults to the first item on the list, "Indirect".
<SELECT dataFld=Direct dataSrc=rsTypeData id=select1 name=selNewDirect size=1>
<OPTION <% If rsTypeData.fields.getValue("Direct") = "false" Then Response.Write("selected") End If %> value=0>Indirect</OPTION>
<OPTION <% If rsTypeData.fields.getValue("Direct") = "true" Then Response.Write("selected") End If %> value=1>Direct</OPTION>
</SELECT>
What am I doing wrong? |
Follow Up - Forgot to mention... - april 1/30/2001 9:11:01 PM
|
|

|
|
|
|
|
|
|
|
|
|