[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Deselecting An Option

Posted on 2013-05-18
3
Medium Priority
?
143 Views
Last Modified: 2013-05-23
I have a series of select boxes.  I am trying to deselect an option in one of them,  I tried this, but it does not work.  It is a single select box.

//$("#Alpha option[selected]")[0].selected = false;

Open in new window


www.Menuhead.com/grabbamenu.php

If you select Baltimore / 1 / 13.5 Wine Bar  Then go back and select another city you will see that the filter box remains selected.
0
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:DS928
ID: 39177453
Tried this, and it does not work as well.
$("#Alpha").selectedIndex = -1;

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39177519
http://api.jquery.com/prop/
http://api.jquery.com/removeProp/

$("#Alpha>option:checked").removeProp("selected");
0
 

Author Comment

by:DS928
ID: 39177537
Thank you.  Yes it works, but.....it also deselects immediately as opposed to deselecting when the city is selected.

$(document).ready(function() {
			$('#City, #Alpha').change(function() {
			//get the values
			city = ($('#City').val());
			alpha = ($('#Alpha').val());

			//if both values are set, fire the ajax call
			if (city && alpha) {
			$.ajax({
				type: "POST",	
				url: "../Scripts/alpha_search.php",
				data: {"Letter": alpha, "Cid": city},
				success: function (html) {
					$("#Alpha>option:checked").removeProp("selected"); 
					$("#Restaurant").html(html);
					$("#BigName").html("");
					$("#BigPhone").html("");
					$("#Menus").html("");
					$("#MyMenus").html("");
				}
			});
		} else {
			$("#Alpha>option:checked").removeProp("selected"); 
			$("#Restaurant").empty(); 
			$("#BigName").html("");
			$("#BigPhone").html("");
			$("#Menus").html("");
			$("#MyMenus").html("");
			$("#RestMenus option").remove();
		}
	});
});

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question