Solved

Get Value OnChange

Posted on 2009-07-08
5
407 Views
Last Modified: 2012-06-21
I have a dropdown that i set a dynamic id, onChange i want to get the value of the dropdown dynamic id.

I want to dynamically add the on change attribute to something like:

mydropdownlist.attributes.add("OnChange",'GetMyValuefortheDynamicID')




Dynamic id for dropdown: id can be any number given to it
 
<asp:dropdownlist runat="server" id="12345">
<listitem>a</listitem>
<listitem>b</listitem>
<listitem>c</listitem>
</asp:dropdownlist>

Open in new window

0
Comment
Question by:Padre_Corleone
[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
  • 2
5 Comments
 
LVL 2

Expert Comment

by:jainnaveen
ID: 24801314
this.id in the function will dropdown list id
0
 
LVL 7

Author Comment

by:Padre_Corleone
ID: 24801322
i have the Id but need the value when user changes dropdown though
0
 
LVL 2

Accepted Solution

by:
jainnaveen earned 500 total points
ID: 24801373
mydropdownlist.attributes.add("OnChange",'getValue(this.id)')

function getValue(sel_id)
{
      var list = document.getElementById(sel_id)
      alert(list.options[list.selectedIndex].value)
}
0
 
LVL 9

Expert Comment

by:Graceful_Penguin
ID: 24801376
I don't know asp but why don't you output the onChange event as an attribute of the select from the server where you generate the html for the select?
0
 
LVL 7

Author Comment

by:Padre_Corleone
ID: 24801444
thanks jainnaveen that did it.

Graceful one: i am trying to avoid using server side to improve performance.  thanks.
0

Featured Post

Independent Software Vendors: 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
Add - in a loop to first and last element. 6 59
Where is this content coming from? 4 38
jQuery element reference issue 2 37
Form submit takes only for one form 23 50
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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?
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…

739 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