Skip to content Skip to sidebar Skip to footer

Problem In Getting Right Result For Select Box

i am using Jquery as: $(document).ready(function(){ test('price'); alert('hi'); $('#item2').change(function() { sort= $('#item2').val(); test(sort); }

Solution 1:

Your question isn't particularly clear, but your alert code only fires when the document is ready - it is not inside the "change" event function.

Try using the following to see what value is being returned when you change the select box:

$(document).ready(function(){
 test("price");
 $("#item2").change(function() 
    { 
        sort= $("#item2").val(); 
        alert(sort);
        test(sort);
    }); 
 });

When changing the select box, you should get an alert with the value you have chosen, which will help you understand why the test() function isn't functioning as you expect.

If you amend your question to include the HTML of the select box and the test() function itself I will amend my answer to help.


Solution 2:

The JQuery code that you have posted is working fine. Demo: http://jsfiddle.net/DtnUr/

We need more details to figure out the issue, such as your HTML code and JS functions.


Post a Comment for "Problem In Getting Right Result For Select Box"