• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

Pass a reference to a dropdown menu

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
dshrenik
Asked:
dshrenik
2 Solutions
 
leakim971PluritechnicianCommented:
<select onchange="myfunction(this.value)">
0
 
dshrenikAuthor Commented:
I want to pass the whole dropdown menu as a parameter (not just its value).
0
 
Gurvinder Pal SinghCommented:
<<I want to pass the whole dropdown menu as a parameter (not just its value).>>
<select onchange="myfunction(this)">
0
 
jjperezaguinagaCommented:
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now