Jump to content

Clear selected option value if another one is selected


rx3mer

Recommended Posts

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 
	        }
	      }
	   });
	 });
});

image.jpg

 

Basically all i want is the last selected value to be passed to the invite on click.

 

Any suggestions?

 

  • 3 weeks later...

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

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.