Solved

how to open dropdown menu on page load without having to click?

Posted on 2016-09-23
4
61 Views
Last Modified: 2016-10-10
On a page, I have a dropdown. I want it to open when page loads. Thanks for your help.

Here is my drop down code:


<select name="pgnames" align="absmiddle" onChange="nav()" onload="toggle()">
<option value="">--- By Practice Group ---</option>
<cfoutput query="getPGNames"><option value="#pgnumber#"<cfif isdefined("pg")><cfif pg EQ #pgnumber#> selected</cfif></cfif>>#PracticeGroup#</option></cfoutput>
</select>
0
Comment
Question by:Member_2_7971128
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
zephyr_hex earned 500 total points (awarded by participants)
Comment Utility
One way to do this would be to change the size attribute of the select.  Here is a simple demo:

JS Fiddle Demo

HTML
<div>
  <select id="mySelect">
    <option>Select Me!</option>
    <option>Foo</option>
    <option>bar</option>
  </select>
</div>
<div>
  <input type="button" id="myBtnOpen" class="myBtn" data-size="3" value="Open It!">
  <input type="button" class="myBtn" data-size="1" value="Close It!">
</div>

Open in new window


jQuery
$('.myBtn').on('click', function() {
  $('#mySelect').attr('size', $(this).data('size'));
});

$('#myBtnOpen').click();

Open in new window

0
 
LVL 42

Expert Comment

by:zephyr_hex
Comment Utility
Did this answer your question?
0
 

Author Comment

by:Member_2_7971128
Comment Utility
I am really sorry I was away. I gave it a try. No it didn't work.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now