Solved

JavaScript/jQuery: Open Select Options upon Trigger

Posted on 2013-05-23
3
1,164 Views
Last Modified: 2013-06-03
Is it possible to open the select options with jQuery?

This does NOT work:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

 $('#openSSS').click(function(){
  $('#sss').click();
 });

});

</script>
</head>
<body>

<select name="Choose_One" id="sss"> 
<option value="a">Option 1</option> 
<option value="b">Option 2</option> 
<option value="c">Option 3</option> 
<option value="d">Option 4</option> 
<option value="e">Option 5</option> 
</select> 

<input type="button" value="Click to open the select" id="openSSS" />

</body>
</html>

Open in new window

0
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 15

Expert Comment

by:Jagadishwor Dulal
ID: 39191296
Why not? You have make just a small mistake see

<script type="text/javascript">
$(document).ready(function(){

 $('#openSSS').click(function(){
  var selval=$('#sss').val();
  alert(selval);
 });

});

</script>

Open in new window

0
 
LVL 16

Author Comment

by:hankknight
ID: 39191513
That solution is useless.  I want the options to slide down when you click on the button.  I do not need an alert!
0
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 500 total points
ID: 39191525
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

809 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