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
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help! combobox NOT updating

    Hi Please help, i am terribly confused and never encountered this before.

    I have a search screen which based on the dropdown box choice, displays fields, name address etc.

    So i select the dropdown box and choose "First Name / Last Name". I input values into the newly displayed FName and LName text boxes that are displayed.

    Search executes and returns values, the Combo Box displays "First Name / Last Name". However I want it to return to the default Combo Box value.
    (This is coming from the lead not me i know its foolish).

    So i use
    var selection = document.getElementById("ComboBox0");
    selection.selectedIndex = 0;

    and if I run AFTER the above line
    alert(selection.selectedIndex);
    alert(selection.value);

    I see 0 and Default

    BUT the text within the combo box is still displayed as "First Name / Last Name"

    what am i doing wrong here?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,557
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    Not enough code.

    Perhaps something is changing the selection *AFTER* you change selectedIndex to zero.

    We can't tell from the fragment you posted.

    WHEN, for example, do you set that selectedIndex to zero??? I would have assumed you might do it via <body onload=...> ??

  • #3
    New Coder
    Join Date
    Aug 2008
    Posts
    22
    Thanks
    0
    Thanked 2 Times in 2 Posts
    try checking the html using view source / view page source.
    make sure that it isn't written like this :

    Code:
    <select name="ComboBox0" id="ComboBox0">
    <option value="Default">First Name / Last Name
    ...
    </select>

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,557
    Thanks
    80
    Thanked 4,620 Times in 4,583 Posts
    LOL! Good catch! Checking the .value doesn't really say anything about the displayed text. My hunch is that this is not the problem, but sure would be fun if it is!

  • #5
    New Coder
    Join Date
    Aug 2008
    Posts
    22
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Its because I've seen scripts printing the first option with previous selection.
    And as you've already said that there's not enough code to analyze the problem.


  •  

    Posting Permissions

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