Take the 2-minute tour ×

Okay, I know that my title is not very informative. Let me explain.

There is a page I am trying to do over with jQuery. On their page (the old page), there is a select dropdown menu that I am bringing over to my (new) page. Their select dropdown is using a ul with li elements, while mine is using select with option elements.

Here is what I have:

var totalQuestions = jQuery('.rcbItem').length; //get the total elements in theirs

for ( x = 0; x < totalQuestions; x++) //for loop to create the dropdown on mine
    var questionText = jQuery('.rcbItem:eq(' + x + ')').html();

        'value' : "Question" + x

var strQuestion = jQuery('#ctl00_ContentPlaceHolder1_ddlQuestion_Input').val();  //gets the value currently in THEIR select field

var objQuestionNext = jQuery("#selectQuestion").find("option:contains('" + strQuestion + "')");

    selected : 'true'
});  //finds the question in MY list that matches THEIR select field, and then selects that one

This is the code that runs every time I select a question from my dropdown list:

    strQuestion = jQuery('#selectQuestion :selected').val(); //get the value of "option", which is Question + x
    strAnswer = jQuery('#txtQuestionAnswer').val();

    intQuestionNumber = strQuestion.substr(8, 2).trim(); //gets the number (so Question + x becomes x)

    jQuery('#ctl00_ContentPlaceHolder1_ddlQuestion_Arrow')[0].click(); //I click THEIR dropdown menu

    jQuery('.rcbItem:eq(' + (intQuestionNumber-1) + ')').click();  //Select THEIR li element that matches MINE)


This works 90% of the time.

However, if I choose the very last option in my list, this is what happens. It selects it, which is fine, but if I then choose another question from the list, it starts selecting the one directly above the one that I want, and continues to do that until I completely reload the page. This ONLY happens if I choose the very last element in my dropdown.

I have been racking my brain about this and have not found an answer. Can anyone offer some insight? Thanks.

EDIT: I finally found the problem. In their code, the .rcbItem class that every one of their li elements had was being overwritten by a .rcbHover class when the click happened. So to fix it, I basically changed .rcbItem to jQuery('.rcbList li').... and it works perfectly now.

Thank you for your help guys.

share|improve this question
Have you tried debugging it to see where it's going wrong? Could you create a demo on jsfiddle.net? –  James Montagne Feb 12 '13 at 15:31
At least showing us some HTML markup would helpful. –  kidwon Feb 12 '13 at 15:32
Unfortunately, I don't have any HTML to give you. The only thing I've touched on the page is the Javascript. Their stuff is heavily coded in ASP, not HTML, and I cannot touch any of that because it's their code. –  snowfi6916 Feb 12 '13 at 15:36
Odd that you were able to get all these class and variable names without any HTML...? –  jmorc Feb 12 '13 at 15:48
@snowfi6916 Open your browser and go to "view source". If the elements are created dynamically, every modern browser still has some way of retrieving the HTML. –  James Montagne Feb 12 '13 at 15:49

1 Answer 1

Are you sure that this one is OK?


You trigger jQuery's .click not on jQuery but on DOM element

share|improve this answer
That particular ID belongs to an "a" element, so I'm pretty sure that's okay. –  snowfi6916 Feb 12 '13 at 16:09

Your Answer


