Results 1 to 6 of 6

Thread: Drop-down list problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219

    Drop-down list problem

    Dear all,
    Im populating data from the database into a drop-down box.
    Its working fine as far as putting the data from the db to the drop-down.
    My problem is when I want a particular record's value has to be displayed after populating, how do i do that?
    For instance, the drop-down already has populated data (1,2,,,10)
    I want the drop-down to show 5 (with 1..10 being there in the drop-down), how do I do that?

    Thanx in advance

    Parasuraman
    Om Nama Sivaya!!!

  2. #2
    chenko
    Guest
    <OPTION value=1 selected>1</OPTION>


    Simon

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Thanx Simon,
    But, if the value in the drop-down is going to be dynamic, I want to mix it with asp and html code. i have problem in that.
    Any advise?

    thanx again
    Om Nama Sivaya!!!

  4. #4
    chenko
    Guest
    Well the user dosent see the ASP

    I think i have an idea, as you loop thru do a simple If...Then, if its the one you want to be selected, put in the "selected" if not leave it


    quick example, hopefully should give you and idea......
    Code:
    Dim i
    Dim SelectedNumber
    
    SelectedNumber = 5
    
    For i = 1 to 10
       If i = SelectedNumber Then
            Response.Write("<OPTION value=" & i & " selected>" & i & "</OPTION>")
       Else
            Response.Write("<OPTION value=" & i & ">" & i & "</OPTION>")
       End If
    Next i

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Dear Chenko,
    Thats a good idea. Thanx for that. I'll try that logic

    Cheers

    Parasuraman
    Om Nama Sivaya!!!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2001
    Location
    Chennai, India
    Posts
    219
    Dear Chenko,
    The logic is working fine. Thanx alot

    Thanx again

    Parasuraman
    Om Nama Sivaya!!!

Posting Permissions

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



Click Here to Expand Forum to Full Width