rx3mer Posted March 30, 2014 Share Posted March 30, 2014 Hi guys, I have a select option list with different values that come from MYSQL. 1,2,3,4,5,6 etc... Basically when I select one, and then change my mind and select another option from the list 2 of the values are stored and parsed to my ajax. I tried different methods such as empty(); inside the optionbox on click but nothing seems to reset it. $(".optionbox").click(function(){ var CASE_ID = $(this).attr('playlistID'); console.log(CASE_ID); $(".invite").click(function(){ $.ajax({ type:'POST', url:'processing/invite-user.php', data:'playlistID=' + CASE_ID, success:function(data) { if(data) { // DO SOMETHING } else { // DO SOMETHING } } }); }); }); Basically all i want is the last selected value to be passed to the invite on click. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/287397-clear-selected-option-value-if-another-one-is-selected/ Share on other sites More sharing options...
denno020 Posted April 17, 2014 Share Posted April 17, 2014 Do you see both of the ID's on the server? Or are you just going by what's displayed in your console? Every time you 'change your mind', and select a different option, your console.log will run, which is why you're seeing both 2 and 10. Move your console.log call into the .invite click function, and that will be the value that was sent to the server, as it will only be execute when you effectively execute the ajax. Hope that helps Denno Quote Link to comment https://forums.phpfreaks.com/topic/287397-clear-selected-option-value-if-another-one-is-selected/#findComment-1476498 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.