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?

 

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.