Click here to Skip to main content
15,907,905 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is it possible to make a listbox visible false if I click anywhere on the form outside the listbox. Please advice me.
Regards.
Posted
Comments
Sergey Alexandrovich Kryukov 14-Jan-13 23:27pm    
What par of it is your problem. Do you understand that if you hide something this way, you will also need to show it? :-)
—SA

1 solution

If i understand your correction correctly you want to make it where if you lose focus on your listbox that it disappears correct?

Try the code below. Im assuming you have basic understanding of jquery/can call jquery.

JavaScript
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){
	$("#IdOfYourListBox").live("blur", function(){
		$("#IdOfYourListBox").hide();
	});
});
</script>
</head>
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 14-Jan-13 23:26pm    
Not bad, but this way you will hide poor control forever. :-)
Of course, OP did not ask about that, but if we asked exact question as they are posed by unsuspecting inquirers, we would hardly really help anyone... so how about adding some code to show the control again? It will need some other control, a target of some event...
—SA
David_Wimbley 14-Jan-13 23:28pm    
As i wrote the snippet i realized that as well but the question was to make it disappear so call me houdini. :-D
Sergey Alexandrovich Kryukov 14-Jan-13 23:31pm    
:-)
Houdini actually re-appeared, even after being tied. Will OP's "requirements" tie you more? :-)
—SA
David_Wimbley 14-Jan-13 23:32pm    
I guess if the requirements change i can find away to make a special appearance and re-appear. :-D
Sergey Alexandrovich Kryukov 14-Jan-13 23:34pm    
:-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900