Click to See Complete Forum and Search --> : Drop-down list problem
Parasu Raman
Jul 6th, 2001, 03:41 AM
Hi all,
I have a drop-down listbox in my ASP page. I populate its content from a database. When the user chooses a value, it gets stored in the database only partially.
For instance, if I choose 'ABC Company Ltd', it gets saved onyl as 'ABC'. Similarly, it gets saved only till the blankspace.
Any guess why this is like this? I checked for ehe entire code, its all correct.
Kindly help
chenko
Jul 6th, 2001, 03:43 AM
in the value make sure you have " " or ' 'around the text
value="ABC Company Ltd"
Parasu Raman
Jul 6th, 2001, 04:00 AM
Hi Chenko,
Here is the code which I use. Kindly help me
<select name="brk_air">
<%
' dim var_sel_brk_air
rs.open "select * from schenker_master",cn,0,1
rs.movefirst
while not rs.EOF
if rs("prospect_id") = var_ses_pros_id then
var_sel_brk_air = rs("brk_air_name")
end if
rs.movenext
wend
rs.close
rs.open "select * from schenker_broker_air",cn,0,1
rs.movefirst
while not rs.EOF
if rs("brk_air_name") = var_sel_brk_air then
response.write ("<option value=" & rs("brk_air_name") & " selected>" & rs("brk_air_name") & "</option>")
else
response.write ("<option value=" & rs("brk_air_name") & ">" & rs("brk_air_name") & "</option>")
end if
rs.movenext
wend
rs.close
%>
</select>
</td>
</tr>
..
..
chenko
Jul 6th, 2001, 04:18 AM
Originally posted by Parasu Raman
Hi Chenko,
Here is the code which I use. Kindly help me
<select name="brk_air">
<%
' dim var_sel_brk_air
rs.open "select * from schenker_master",cn,0,1
rs.movefirst
while not rs.EOF
if rs("prospect_id") = var_ses_pros_id then
var_sel_brk_air = rs("brk_air_name")
end if
rs.movenext
wend
rs.close
rs.open "select * from schenker_broker_air",cn,0,1
rs.movefirst
while not rs.EOF
if rs("brk_air_name") = var_sel_brk_air then
response.write ("<option value='" & rs("brk_air_name") & "' selected>" & rs("brk_air_name") & "</option>")
else
response.write ("<option value='" & rs("brk_air_name") & "'>" & rs("brk_air_name") & "</option>")
end if
rs.movenext
wend
rs.close
%>
</select>
</td>
</tr>
..
..
Ok, ive edited your code, I put ' ' in as you are using response.write, and also you needed a space before the "selected"
Parasu Raman
Jul 6th, 2001, 04:33 AM
Chenko,
Thanx alot. It works perfect.
monte96
Jul 6th, 2001, 12:25 PM
On a side note, why don't you use where clauses in your SQL statements. You should not load all the data then loop through it to find one record. Just ask the database for the record that matches your criteria.
Parasu Raman
Jul 7th, 2001, 01:23 AM
Hi Monte96,
Thats a good idea. I'll do that hereafterwards. I understand that it reduces the retrieval time
Thanx again
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.