SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2009
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update database in ASP

    hello to all, i am making an application in asp.I have two combo box ..now suppose i save selected item from two combo in the database..

    now i want that when i click on update button the two combox box should come with that saved selected value along all the another values also..

    Can anyone help me please???

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    do u mean something like this?

    Code:
    <select name="options">
    <option value="opt1"
    if RS("something") = "opt1" then
    selected="selected">
    end if
    opt1</option>
    ...
    </select>

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have taken the combo box data from a table. I have made the below code.Please guide how to change the below data.

    <% SQL ="Select City From City order By City"
    Set rs = sconn.Execute(SQL)%>
    <select name="Location" size="1">
    <option >- Select -</option>
    <%while not rs.EOF%>
    <option value=<%=rs(0)%>><%=rs(0)%></option>
    <%RS.MoveNext
    wend%>
    </select>

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,037
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by smita86 View Post
    i have taken the combo box data from a table. I have made the below code.Please guide how to change the below data.

    <% SQL ="Select City From City order By City"
    Set rs = sconn.Execute(SQL)%>
    <select name="Location" size="1">
    <option >- Select -</option>
    <%while not rs.EOF%>
    <option value=<%=rs(0)%>><%=rs(0)%></option>
    <%RS.MoveNext
    wend%>
    </select>
    Well ulthane has provided the conditional logic to do the trick but we need to know which city we are viewing... Have you passed that through a querystring argument or is it an ID that we pull from the database?

    Assuming we know what city we are viewing and put that value in a variable called varCity You need to use it in your code as follows:

    Code:
    <%
        varCity = 'The city we're looking at
        varSelected = "" 'This is just the string we use to bookmark the drop down
    %>
    
    <%while not rs.EOF%>
    <%
        if varCity = rs(0) then
            varSelected = "selected = ""selected"""
        end if
    %>
            <option <%=varSelected%> value=<%=rs(0)%>><%=rs(0)%></option>
            <%
       varSelected = ""
       RS.MoveNext             
        wend
    %>
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development


Bookmarks

Posting Permissions

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