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)

    Question Convert JSP code in ASP

    i want to Convert the below given jsp code in asp.
    <select size="1" name="s" style="width: 150">
    <option <%=s.equals("abc") ? "selected" : "" %> value="abc">abc</option>
    </select>.

    Please guide.

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code ASP:
     
    <select size="1" name="s" style="width: 150" value="abc">
    <option <% if  [put option value here]="abc" then response.write( " selected " )  %> >abc</option>
    </select>.

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    iT DOESNT WORKS.

    I have exactly this code.

    <% 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>
    I have two combo box like this..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...
    Please guide how to make changes in this.

  4. #4
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    before it can be shown as selected you must have two things

    1] a comparison check to find a match and
    2] the word "selected" placed into the option tag

    Code ASP:
     
    <select name="Location" size="1">
    <option >- Select -</option>
     
    <% 
    SQL ="Select City From City order By City"
    Set rs = sconn.Execute(SQL)
    while not rs.EOF
     
    'initialize value for select
    '-------------------------------
    vSelected = ""
     
    ' make a comparison 
    '-------------------------
    if rs(0) = "[your comparison value must be provided here]" then vSelected = " selected "
     
    'place selected word into option tag if match exists
    '----------------------------------------------------------------
    %>
    <option <%=vSelected%>value="<%=rs(0)%>"><%=rs(0)%></option>
    <%
    RS.MoveNext
    wend
    %>
    </select>


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
  •