If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Adding data from listbox to database problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-03, 05:45
Simon K Simon K is offline
Registered User
 
Join Date: Sep 2003
Posts: 10
Question Adding data from listbox to database problem

Hi,

I have a form, and in this form there is a listbox which is populated with data from a database (in this case, coursenames). The user selects something from the listbox and fills in the rest of the textboxes in the form. When the user clicks submit, all the data is sent to a table I have created in my database. Everything works fine, except there seems to be a problem with the data being sent from the listbox, in that it is only sending the first word of the coursename (i.e. for a course called 'Train the trainers' only the word 'train' is being sent to my database.

Can anyone shed some light on my problem, and maybe give some help?


This is the code I used to populate my listbox, the value 'test' is just the result of my SQL statement to get all the coursenames.

<select name=courselistbox>
<%
Do While Not display.EOF
response.write "<option value = " & display("Test") & " >"
response.write display("Test") & "</option>"
display.MoveNext
loop
%>
</select>


The code I am using to send my listbox data to my database is as follows, 'Evaluation' being my recordset, and 'training' being the name of the field in my database I would like the data sent to:

evaluation("training") = Request.Form("courselistbox")

Thanks.
Reply With Quote
  #2 (permalink)  
Old 11-11-03, 17:55
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
You need to wrap your value attribute in quotes... thing the chr value for a quote is 32 so you would have something like this...


<select name=courselistbox>
<%
Do While Not display.EOF
response.write "<option value = " & chr(32) & display("Test") & chr(32) & " >"
response.write display("Test") & "</option>"
display.MoveNext
loop
%>
</select>

I think you can also do something like """ to get a quote but I can't remember....

If you look at your html you will be getting something like...

<option value = Train the trainer>

you want

<option value ="Train the trainer">
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On