Jump to content

jquery get value of selection in dropdown


rockinaway

Recommended Posts

i have a dropdown list, and when the value is changed i have a function occurring. it needs the value of the selected option in the dropdown, but i can't see to access it.

 

my code:

$(document).ready(function () {


$('#birthmonth').change(function() {
	var birthmonth = encodeURIComponent($('#birthmonth').val()); 
        
        $.ajax({
          url: 'register.php',
          data: 'change_day='+birthmonth,
          type: 'post',
          success: function (j) {
            if (j == 1)
            {
            	$("select#birthday option[value='30']").remove();
            	$("select#birthday option[value='31']").remove();
            }
            // 31 Days
            else if (j == 2) 
            {
            		$("<option value='30'>30</option>").appendTo('#birthday');
            		$("<option value='31'>31</option>").appendTo('#birthday');
            }
            else if (j == 3)
            {
            	$("<option value='30'>30</option>").appendTo('#birthday');
            	$("select#birthday option[value='31']").remove();
            }
            
          }
        });
    });
});

 

Through firebug, I see that the result, instead of the value is: '[object HTMLSelectElement]'

 

What do I need to do?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.