Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts

    select box default value

    is there any way to set the default value of select box
    I HAVE



    <SELECT NAME='bar_FOO' >


    <OPTION VALUE="4" > </OPTION><OPTION VALUE="4" > </OPTION><OPTION VALUE="4" > </OPTION><OPTION VALUE="4" > </OPTION>

    </SELECT>
    I am not auto generating the options from database but i want to pre select the field if user want to edit their detail
    Please de-reputate me
    0o0o0o0

    Its better to rule in Hell then to serve in Heaven

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    Add selected="selected" to the required option
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    BUt the problem is i have 20 predefined option tags hard coded in html
    and in database i have only value

    so i can't use selected
    Please de-reputate me
    0o0o0o0

    Its better to rule in Hell then to serve in Heaven

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    that can be the other way.
    Can i do like this

    PHP Code:
    <select>
    <option value="<?php echo value ?>" selected="selected"><?php echo value ?> </option>
    <OPTION VALUE="4" > </OPTION>
    <OPTION VALUE="4" > </OPTION>
    <OPTION VALUE="4" > </OPTION>
    <OPTION VALUE="4" > </OPTION>

    </select>
    I mean one extra row for the item in database
    Although there will be duplicate row but solves the purpose
    Please de-reputate me
    0o0o0o0

    Its better to rule in Hell then to serve in Heaven


  •  

    Posting Permissions

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