Solved

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

Posted on 2016-09-23
4
193 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
Suggested Courses

624 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