Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Angry Unanswered: Setting drop-down initial value in an update form

    I am trying to create a form that will update a record in an access database. I have successfully created the ASP pages to add the records to the database and I am working on a page to update records in the database. (Using the DRW in Frontpage)

    I am using one database with two tables (virtual library). The 'Books' table contains the fields for the ID, title, publisher etc and the 'Categories' table contains a list of categories that the book may belong in and the table ID.

    I have successfully added the 'categories' drop down, but the problem is that I need it to have the same initial value that the current database record has.

    For instance, the field in the database called Categories was populate with 'Training' when the record was entered. When I bring up the form to edit this record I would like the drop down to be populated with 'Training' for this record. I currently have an option that shows me the first value in the table which is 'Acts'.

    How do I get the form to conditionally set the initial value of the drop down list?

  2. #2
    Join Date
    Sep 2003
    Location
    United States
    Posts
    1
    Have you tried <%=rs("FieldName")%> for the value in the drop down box tag?

  3. #3
    Join Date
    Oct 2003
    Location
    Dallas
    Posts
    76

    something like this should work

    <%
    do connection and run query

    If not RS.EOF Then
    Utility = RS("utility")

    End If

    dbconnection.Close
    %>

    <form method="post" name="UpdateAppl">

    <P>
    <select name="S_utility" size="1" tabindex="5" >

    <%if Utility = "E" then %>
    <option SELECTED value="E"> Electric </option>
    <%else%>
    <option value="E"> Electric </option>
    <%end if %>
    <%if Utility = "G" then %>
    <option SELECTED value="G"> Gas </option>
    <%else%>
    <option value="G"> Gas </option>
    <%end if %>
    </select>

Posting Permissions

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