rockinaway Posted August 30, 2011 Share Posted August 30, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/246064-jquery-get-value-of-selection-in-dropdown/ Share on other sites More sharing options...
rockinaway Posted August 31, 2011 Author Share Posted August 31, 2011 any help? Quote Link to comment https://forums.phpfreaks.com/topic/246064-jquery-get-value-of-selection-in-dropdown/#findComment-1263838 Share on other sites More sharing options...
rockinaway Posted August 31, 2011 Author Share Posted August 31, 2011 Okay it's the encodeURIcomponent that is doing it. I've removed it, why does it cause that? Quote Link to comment https://forums.phpfreaks.com/topic/246064-jquery-get-value-of-selection-in-dropdown/#findComment-1263843 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.