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

Drop down inputbox

Status
Not open for further replies.

Aladdin420

Programmer
Jan 5, 2001
33
0
0
US
Hi all, wanted to know if there's some way of constructing a drop down input box in VBScript. I have gone bananas looking for it, but it seems that this feature is not given with VBScript or the WSH.

This is what I wanted to do, for example:

An inputbox will pop up and ask the user to chose from the drop down menu. There will be 5 choices from which the user can chose from, with one of the choices being the default choice. The user choses one by clicking "Okay".
I hope the problem is clear.

thanx
Aladdin420
 
Here is what you do:

<SELECT id=select1 size=1 name=select1>
<option value=0>--Default Choice--</option>
<option value=0>--Choice 2--</option>
<option value=0>--Choice 3--</option>
<option value=0>--Choice 4--</option>
<option value=0>--Choice 5--</option>
</SELECT>

If you don't want to use an &quot;Okay&quot; button, add an &quot;onChange&quot; to your opening select tag and call a javascript that submits the choice for user when he/she makes a choice. All of the above is written in HTML.

If you are trying to pull information from a table and want it to display in a drop down, do the following:

set rs = server.CreateObject(&quot;adodb.recordset&quot;)
sql = &quot;select itemvalue, itemname from table order by itemname asc&quot;
rs.open sql, data, 0,1

<SELECT id=select1 size=1 name=select1>
<% do until rs.eof
Response.Write &quot;<OPTION value='&quot; & rs(&quot;itemvalue&quot;) & _
&quot;'>&quot; & rs(&quot;itemname&quot;)& &quot;</OPTION>&quot;
rs.movenext
loop%>
</SELECT>

Hope this helps!
Frog
 
Hey Frog,
I was hoping to get an answer within VBScript, dude. Is there some way of calling an html or javascript code in VBScript that would help me to do the following task:

I want to read from a file that will have the following text:

'*****
Fall
Summer
Winter
Spring
'*****

I want to read this texts and place every line into the drop down menu. For Example, if u were to click on the drop down arrow, it would show you the four seasons as written in the text file.
Help!!!!!!

Thanx

aladdin420
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top