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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field editing and dropdowns

Status
Not open for further replies.

charanch

Programmer
Jan 3, 2004
55
US
Hello,

I am trying to do some dynamic content editing and have a few fields that were inserted from a dropdown box. When the user wants to edit the record, what is the best way to show the dropdown box dynamically. i.e. my code is like this:

set rs=db.execute("select * from workstations where customerid=" & custid)
if not rs.eof then
for each fld in rs.fields
if fld.name="os_id" then
response.write &quot;<select name=os>&quot;

*** here's where I need to show the dropdown for operating systems and show selected the actual record value ** Then do I have to do another recordset of the operating systems table??? Isn't there a better way?

response.write &quot;</select&quot;>
else
response.write fld.name & &quot; <input type=text name=&quot; & fld.name & &quot; value=&quot; & fld.value & &quot;>&quot;
end if

I very much appreciate any ideas anybody has. Thanks very much.

 
use an array to hold the values unless they are added to or changed frequently, in which case you use the db to provide a list and create move thru that to select the option

Using array
Code:
myOS = array(&quot;Windoze&quot;,&quot;Unix&quot;,&quot;Linux&quot;)

myDBValue= rs(&quot;OS&quot;)  for this example I will assume 1 OS

for x=1 to Ubound(myOS)

   if myDBValue= myOS(x) then
    
      response.write &quot;<option value=&quot;&quot; & myOS(x) & &quot;&quot; Selected>&quot; & myOS(x)

   else

      response.write &quot;<option value=&quot;&quot; & myOS(x) & &quot;&quot; &quot; & myOS(x)

You don't mention how many OS' there are allowed to be in the drop down - > this would work if the Select was MULTIPLE as well (ie the dropdown allowed more than one choide)

hth

Bastien

Any one have a techie job in Toronto, I need to work...being laid off sucks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top