Jump to content


Photo

Clear selected option value if another one is selected

option

  • Please log in to reply
1 reply to this topic

#1 rx3mer

rx3mer

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts
  • LocationUK

Posted 30 March 2014 - 02:29 PM

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?

 



#2 denno020

denno020

    Advanced Member

  • Members
  • PipPipPip
  • 712 posts
  • LocationAustralia

Posted 17 April 2014 - 07:30 AM

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






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com