Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    10

    Question Unanswered: 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.

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    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">

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •