Solved

Pass a reference to a dropdown menu

Posted on 2011-09-18
4
251 Views
Last Modified: 2012-05-12
Please let me know how I can pass a reference to a dropdown menu as a parameter to a function in JavaScript.

If possible, please provide some sample code. Thanks!
0
Comment
Question by:dshrenik
4 Comments
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
<select onchange="myfunction(this.value)">
0
 

Author Comment

by:dshrenik
Comment Utility
I want to pass the whole dropdown menu as a parameter (not just its value).
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 450 total points
Comment Utility
<<I want to pass the whole dropdown menu as a parameter (not just its value).>>
<select onchange="myfunction(this)">
0
 
LVL 6

Assisted Solution

by:jjperezaguinaga
jjperezaguinaga earned 50 total points
Comment Utility
Greetings dshrenik,

Gurvinder372 is correct; "this" is the best way to send an object to a function. If you are familiar with jQuery, you can always call the form through an ID and query its elements: http://jsfiddle.net/YXagh/1/

Best regards,
-JJ
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

763 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

11 Experts available now in Live!

Get 1:1 Help Now