...

View Full Version : drop down box Help



newkid
08-18-2004, 09:54 PM
Never mind, I just need to learn how to type :o
(See answer below, just in case I'm not doing to correctly pls)



ok here's the drop down box for my add screen (works fine)



<select name="Salutation" size="1">
<option selected="selected">Salutation </option>
<option value="Mr">Mr. </option>
<option value="Ms">Ms. </option>
<option value="Mrs">Mrs. </option>
</select>


And here's what I have on my modify screen (works fine)



<input type="text" name="Salutation" value="<%=(rsUnProc.Fields.Item("Salutation").Value)%>" size="32">


what I want to do is have a drop down on my modify screen (vice an input box), but I'm not sure how to set up the select to have an initial value of <%=(rsUnProc.Fields.Item("Salutation").Value)%>


Thanks in advance for any help
J.C.
To learn is a good thing and today I hope to learn something new!!

ANSWER:
(If this is not the correct way please let me know but it did work)


<select name="Salutation" size="1">
<option selected="selected"><%=(rsUnProc.Fields.Item("Salutation").Value)%></option>
<option value="Mr">Mr. </option>
<option value="Ms">Ms. </option>
<option value="Mrs">Mrs. </option>
</select>

Morgoth
08-18-2004, 10:47 PM
<select name="Salutation" size="1">
<option selected="selected"><%=(rsUnProc.Fields.Item("Salutation").Value)%></option>
<option value="Mr">Mr. </option>
<option value="Ms">Ms. </option>
<option value="Mrs">Mrs. </option>
</select>


First off, I don't think selected="selected" is a real property. To make the box selected you just add the word "selected". Ex. <option value="blah" selected>

It looks like you are a little confused, I think. In your modify screen it should allow you to change your answer in your drop down field, right, because you are modifing something for the database, correct?

Here's what I would have done.


<%
If rsUnProc.Fields.Item("Salutation").Value = "Mr" Then
intSelected(0) = " selected"
ElseIf rsUnProc.Fields.Item("Salutation").Value = "Ms" Then
intSelected(1) = " selected"
ElseIf rsUnProc.Fields.Item("Salutation").Value = "Mrs" Then
intSelected(2) = " selected"
End If
%>
<select name="Salutation" size="1">
<option value="Mr"<%=intSelected(0)%>>Mr. </option>
<option value="Ms"<%=intSelected(1)%>>Ms. </option>
<option value="Mrs"<%=intSelected(2)%>>Mrs. </option>
</select>


This way, you will only have 3 options in the drop down menu. No two will look the same. You also forgot the value for the default selected, which is bad because if you submited the modified page, it wouldn't know what the Salutation is.

Also, I give you a "Check Plus" on indenting!

glenngv
08-19-2004, 03:52 AM
First off, I don't think selected="selected" is a real property. To make the box selected you just add the word "selected". Ex. <option value="blah" selected>

In XHTML, all attributes must have a value. So selected="selected" is fine.

newkid
08-19-2004, 04:15 PM
Thanks Morgoth, glenngv for the help

J.C.
To learn is a good thing and today I have learned something new!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum