Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2016-09-23
4
Medium Priority
?
314 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 44

Accepted Solution

by:
zephyr_hex (Megan) earned 2000 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 44

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

916 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