Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show current value on drop down 1

Status
Not open for further replies.

schase

Technical User
Sep 7, 2001
1,756
US
Setting up an edit page for records. And I'd like to
set up drop downs populated with possible selections for the user.

How can I show the existing value of the record, and let it resubmit with that value if it is not changed?

Thanks in advance
"I like a man who grins when he fights."

-- Prime Minister Winston Churchill

Stuart
 
not sure I follow but if it's all you want is for the dropdown to be poopulated and not have the first value be select something but instead a value from the DB just don't ad a selection that contains a blank so the first value gets resubmited.

This is a way to get a recordset by reading the id # adding the first record to the drop down as the selected.

DIM FirstArray()
REDIM FirstArray(4)
'redim for amount of desc. to be added to selects
strProc=&quot;<SELECT name='firstrecord'>&quot;

DO UNTIL Recordset.EOF

if Recordset(&quot;firstrecord&quot;) = &quot;1&quot; Then
FirstArray(x)=Recordset(&quot;Description&quot;)
'if it is the id i want fill in the record desc.
strProc=strProc & &quot;<OPTION>&quot;
strProc=strProc & FirstArray(x) &
strProc=strProc & &quot;</OPTION>&quot;

end if

Recordset.MoveNext
Loop

strEndSelect=&quot;</SELECT>&quot; I may not get it the 1st or 2nd time,
but how sweet that 15th time can be.
 
<select name = &quot;select&quot;>
<option value = &quot;value1&quot; <% if rs.(&quot;fieldname&quot;)= &quot;value1&quot; then resonse.write(&quot; selected&quot;) %>>value1
<option value = &quot;value2&quot; <% if rs.(&quot;fieldname&quot;)= &quot;value2&quot; then resonse.write(&quot; selected&quot;) %>>value2
<option value = &quot;value3&quot; <% if rs.(&quot;fieldname&quot;)= &quot;value3&quot; then resonse.write(&quot; selected&quot;) %>>value3
</select>

what your html should look like if rs(&quot;fieldname&quot;) = &quot;value2&quot; :

<select name = &quot;select&quot;>
<option value = &quot;value1&quot;>value1
<option value = &quot;value2&quot; selected>value2
<option value = &quot;value3&quot;>value3
</select>
 
Thanks for the response's.

Sorry if I wasnt that clear, Travmak I think is showing close to what I wanted to do. Except the value's are dynamically populated and will change based on what is selected.

tblMenu - has fields menuID, fldMenu, fldUserLevel, fldDepartment, fldLevelNum, fldDeptNum.

The tblMenu is populated with a record insertion form - fields fldUserLevel, fldDepartment,fldLevelNum,fldDeptNum are populated by values from tblDepartment & tblUserlevel.

If I need to edit a record that is in tblMenu already - I'd like for the drop down boxes of fldUserLevel & fldDepartment to show the current value (whatever it may be) then show all available values from their source tables.

So say record 5

fldMenu fldUserLevel fldDepartment
&quot;Edit my Account&quot; &quot;Administration&quot; &quot;Sales&quot;

fldLevelNum fldDeptNum
5 3

I'd want sales to show for the current value in the drop down of the edit page. But be able to see all dept's when I hit the drop down box to update.

Thank you. &quot;I like a man who grins when he fights.&quot;

-- Prime Minister Winston Churchill

Stuart
 
rsdept = selet * from tblDepartment ** I don't know the fields in this table i'll assume fldDepartment**
rsuser = select all that stuff you need where userID = whatever.

<select name = &quot;department&quot;>
<% while not rsdept.eof %>
<option value = &quot;<%=rsdept(&quot;fldDepartment&quot;)%>&quot; <% if rsdept(&quot;fldDepartment&quot;) = rsuser(&quot;fldDepartment&quot;) then response.write (&quot; selected&quot;)%>><%=rsdept(&quot;fldDepartment&quot;)%>
rsdept.movenext
wend
</select>

with luck it should look something like this.

<select value = &quot;department&quot;>
<option value = &quot;Management&quot;>Management
<option value = &quot;Recieving&quot;>Recieving
<option value = &quot;Sales&quot; selected>Sales
<option value = &quot;shipping&quot;>Shipping
</select>
 
I'll give er a shot and let ya know - thanks! &quot;I like a man who grins when he fights.&quot;

-- Prime Minister Winston Churchill

Stuart
 
Your post triggered a slap on my forehead in the way I did it earlier, Dont know why I didn't see it earlier. - Thank you for the help in jogging my mental block. &quot;I like a man who grins when he fights.&quot;

-- Prime Minister Winston Churchill

Stuart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top