|
-
Mar 15th, 2001, 09:38 AM
#1
Thread Starter
Hyperactive Member
Greetings to all my forum buddies!
I know this is a newbie question, but I don't know how to do this in vbscript.
I have a pulldown menu in an edit form. The form calls a recordset and puts the records in their corresponding boxes. I want the pulldown menu, when passed the value, to default to that value. How do I do that with out losing the options in the pull down.
I hope this doesn't sound confusing. Thanks in advance.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Mar 15th, 2001, 08:29 PM
#2
Lively Member
Are the values in your pulldown box coming from a recordset also? Basically, you want to make the value from the recordset selected. Like this:
<option value="1" selected>Option 1</option>
-
Mar 15th, 2001, 10:05 PM
#3
Addicted Member
See this If it helps....
<%
Dim Rating(3),RatingID
'.... Database code ......
'RatingID has a value from the database
'Say the Possible values are 0,1,2,3
'.........................
Rating(RatingID)= "Selected "
%>
<form>
<select name=Ratings>
<option value=0 <%=Rating(0)%>>Poor</option>
<option value=1 <%=Rating(1)%>>Fair</option>
<option value=2 <%=Rating(2)%>>Good</option>
<option value=3 <%=Rating(3)%>>Excellent</option>
</Select>
</form>
-
Mar 16th, 2001, 08:03 AM
#4
Thread Starter
Hyperactive Member
Yes!
Originally posted by chrisgaddy
Are the values in your pulldown box coming from a recordset also? Basically, you want to make the value from the recordset selected. Like this:
<option value="1" selected>Option 1</option>
The values of the pull-down box are not coming from the recordset, but what you said is basically what I want to do. Lemme explain: the pulldown box has selections of 5 values(1 to 5). When they select one and save, a copy of the selected value goes to the recordset. When they want to edit that recordset, I want the value that is being returned to become the default selected. Then, if they need to, they can change it. Therefore, from what you said above, yes I want to make the value from the recordset selected.
Thanks chrisgaddy and Active for all your input.
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
-
Mar 16th, 2001, 08:44 AM
#5
Lively Member
Ok, there's probably 50 ways to do this, and I don't think there's a right or wrong way. There may be a faster way(my favorite), but here's one way:
rs.Open "SELECT * FROM sometable",con,....
Select Case rs("fieldValue")
Case 1
strOptions = "<option value='1' selected>Option1 </option>"
strOptions = strOptions & "<option value='2'>Option 2</option>"
Case 2
strOptions = "<option value='1'>Option 1</option>"
strOptions = strOptions & "<option value='2' selected>Option 2</option>"
and so on and so on....
Now in your html code it should look like this:
<select name="someName"><%=strOptions%></select>
Hope that helps.
-
Mar 16th, 2001, 09:40 AM
#6
Thread Starter
Hyperactive Member
Thanks
That was what I was looking for.
Enjoy your weekend!
-vbuser1976 
VB6 Enterprise SP6
SQL 7.0 SP2
VBScript, HTML, Javascript, C++, a little UNIX
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|