Solved

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

Posted on 2016-09-23
4
134 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
[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
4 Comments
 
LVL 43

Accepted Solution

by:
zephyr_hex (Megan) earned 500 total points (awarded by participants)
ID: 41812663
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 43

Expert Comment

by:zephyr_hex (Megan)
ID: 41827240
Did this answer your question?
0
 

Author Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Attendance Tracking 3 25
Trying to use &NBSP to line up 3 rows 12 40
radio button onclick function 2 15
Ordering displaying data in a drop down 3 14
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

752 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