Results 1 to 2 of 2

Thread: How to select the first value in the drop down as the default value

  1. #1
    Join Date
    Nov 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to select the first value in the drop down as the default value

    Hi Guys,
    I need some help in retreiving the first value in the dropdown list as the default value. The values are retrieved from the Oracle database through the SQl queries. the JS code for that drop down is as follows,

    td.innerHTML = '<select class="formEntryField" name="_' + cr + 'aProbTypeT2' + rc + '" onChange="javascript:document.frmEntry.__' + cr + '.checked = true;" >' + probT2Codes + '<option value="" selected = "selected">* - Not Identified </option> </select>';


    The above query sets the default value as * - Not Identified...but I need that default value to be the first value I get from the database.

    Thanks in advance,
    Kevin

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You really haven't given us much to go on. Of particular interest would be how the rest of the options in the select are created. Just going from what you have shown, I'd say just skip:

    Code:
    <option value="" selected = "selected">* - Not Identified </option>
    That way (presumably), the first option will be the first one from the data base. The first option is always selected by default (at least in modern browsers). You could perhaps arrange though to have it bear the selected attribute. That is recommended, but in all likelihood would not be required.

    This really sounds more like a server side issue, though it does look like you are combining that with javascript. If javascript can be avoided, your page will be more accessible.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •