Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Dropdown box problems
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Dropdown box problems

 Post Reply Post Reply
Author
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Topic: Dropdown box problems
    Posted: 27 February 2005 at 9:44pm

I'm attempting a login script where the available user names are automatically populated in a dropdown box from an sql database.

 

I have used

Set vrec = Server.CreateObject("ADODB.Recordset")
sql = "SELECT CBroker.BrokerOpName FROM CBroker"
vrec.Open sql, adoCon, adLockOptimistic
WHILE NOT vrec.EOF
Response.write "{option name=Vbrok value=" & vrec("BrokerOpName") & ">" & vrec("BrokerOpName") & "{/option>"
vrec.MoveNext
WEND
vrec.Close
 
in between my select and /select tags. The dropdown box displays fine, but if you attempt to post a username which contains a space, it will only post whatever is before the first space, and nothing after. I know that a dropdown box which is hard coded will submit spaced words properly. Does anyone know what i've done wrong?


Edited by ub3rl337ch3ch - 27 February 2005 at 10:03pm
Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadDog Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 9:56pm
Response.write "<option name=Vbrok value=""" & vrec("BrokerOpName") & """>" & vrec("BrokerOpName") & "</option>"
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 10:05pm
cheers... i just worked out a different way, but similar... using '" & blah & "' instead of """ & blah & """
 
Is there going to be any problems you can see using the former as opposed to the latter?
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 10:07pm

Is the full name appearing in the source code ???

Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 10:14pm

I don't know whether this is any use to you matey, but I didn't know anyone used wend any more. Why couldn't you just write it out like this ?? Implementing ASP into the HTML is always easier, and takes less time cos you aint processing all of the response.write stuff

Set vrec = Server.CreateObject("ADODB.Recordset")
sql = "SELECT CBroker.BrokerOpName FROM CBroker"
vrec.Open sql, adoCon, adLockOptimistic
Do WHILE NOT vrec.EOF
%>
 
<option name=Vbrok value="<%= vrec("BrokerOpName") %>"><%= vrec("BrokerOpName") %></option>
 
<%
vrec.MoveNext
loop
 
vrec.Close
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 10:39pm
*feels stupid*
 
I took to writing it all into the asp because the first time i tried looping html it didn't work, obviously (now) because i had a bug somewhere. I used that as a workaround, and have since used looped html, so i probably should have gone back and changed that... but my brain disconnected on that.
 
I suppose i've just used WEND there because i was browsing the web and found it (as opposed to loop) used in an open source eg of an auto populate dropdown
is there actually any any functional difference between the two? like does WEND have bugs that loop doesn't? or is it an ease-of-reading format thing like capitalising If's and End If's?
Back to Top
bootcom View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 February 2005
Location: United Kingdom
Status: Offline
Points: 259
Post Options Post Options   Thanks (0) Thanks(0)   Quote bootcom Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 11:01pm

To be fair, I have never noticed any functional difference between the 2 either but I was talking to one of the guys at the 4guysfromrolla website and he just said that I should stop using WEND as LOOP and DO are now the proper practise, I think WEND was used in the first ASP versions and it's been changed to LOOP although WEND is supported through all versions of ASP. To me it is an ease of use thing (like you say to make it easier to read) although I hardly even use that any more. If your pulling from an access database thats packed, any timesaver is a help so for that I use Arrays.

Instead of:

Set vrec = Server.CreateObject("ADODB.Recordset")
sql = "SELECT CBroker.BrokerOpName FROM CBroker"
vrec.Open sql, adoCon, adLockOptimistic
Do WHILE NOT vrec.EOF
%>
 
<option name=Vbrok value="<%= vrec("BrokerOpName") %>"><%= vrec("BrokerOpName") %></option>
 
<%
vrec.MoveNext
loop
 
vrec.Close
'and set to nothing
set vrec = nothing
%>
 
I just use the following. If your wondering what the 1 relates to in vrecArray(1, x) , this is the 2nd column in your database table (the first - primary key generally is 0,x) The x = 0 to uBound(vrecArray, 2) loops from the first to last record.
 
<%
vrec.Open sql, adoCon, adLockOptimistic
 
' If your database is empty then do something
If vrec.eof then
%>
There are no user's currently in the database
<%
Else
vrecArray = vrec.getRows()
' now loop through your array
For x = 0 to uBound(vrecArray, 2)
%>
<option value="<%= vrecArray(1, x) %>"><%= vrecArray(1, x) %></option>
<%
Next
' close the recordset and reset to nothing
vrec.close
set vrec = nothing
%>
Back to Top
ub3rl337ch3ch View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 February 2005
Location: Australia
Status: Offline
Points: 341
Post Options Post Options   Thanks (0) Thanks(0)   Quote ub3rl337ch3ch Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2005 at 11:25pm
ok thanks.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.