Easiest/cleanest way to get the value of the current element

I want to get the value of the current <input type="radio"> element in its onClick.

I need something like:

<input type="radio" name="myRadio" value="something" onClick="theValueOfThisInput">

I can't use getElementById() because all my radio buttons have the same id.

I've currently done it by wrapping all the inputs in a <div> and getting the elements of the <div> by index, but I won't even bother posting it because I don't think it would be helpful to anyone.

Can someone recommend a good way to do this ?


-------------Problems Reply------------

Have you tried



this.value should certainly work.


<input type="radio"
onclick="alert(this.value)" />

And the 'alert' function can be replaced with whatever function call you wish.

Category:java Views:0 Time:2011-06-13

Related post

  • What's the easiest/cleanest way to get the MessageID of a sent email? 2010-08-12

    I want to save the MessageID of a sent email, so I can later use it in a References: header to facilitate threading. I see in root/django/trunk/django/core/mail.py (line ~55) where the MessageID is created. I'm trying to think of the best way to coll

  • Easiest way to send text from HTML to a .swf element 2011-09-07

    I was trying to send 4 paragraphs to a .swf element. I have no idea how to what to do. I tried using FlashVars but I feel like i need to drop in some actionscript to be able to work with the vars conceptsNdisciplinesPar=(some text)&cultures&c

  • What's the cleanest way to make a Linq object "dirty"? 2009-08-24

    I have a Linq-To-SQL object obj of type MyClass that I have loaded via my data context. Now I want to force that object to save, even if no fields have actually changed, so that the save action can set off some triggers behind the scenes. What's the

  • What's the easiest way to add hotkeys to a webpage? 2011-07-13

    I want to add some hotkeys to my webpage, such as using j/k as page up/down, as this web page did: http://www.theatlantic.com/infocus/2011/07/tour-de-france-2011---part-1/100105/ What's the easiest/cleanest way to do that? Thank you. --------------So

  • What is the easiest way to create an HTML, mouse over tool tip? 2011-09-21

    What is the easiest, cleanest way to create an HTML, mouse over tool tip without using tons of extra js references? <img id=Pennstate src="/blah" style="cursor:pointer;"> mouse over that and have a a nice tooltip "We are Pennstate!" -----------

  • Defining custom actions in Selenium 2008-10-02

    I have a Selenium test case that enters dates into a date selector made up of three pulldowns (year, month, and day). select validity_Y label=2008 select validity_M label=08 select validity_D label=08 This part gets repeated a lot throughout the test

  • How to automate the generation of HTML output in Enterprise Architect 2008-10-21

    Enterprise Architect has a way to generate the documentation in HTML/RTF/etc. that you could publish, but you have to use its GUI to do that manually. When you have your *.eap files in a CVS/Subversion server, it would be useful to have a script that

  • Undoing a commit in TortoiseSVN 2008-10-29

    I commited a bunch of files (dozens of files in different folders) by accident. What is the easiest, cleanest (and safest!) way to 'undo' that commit w/o having to delete the files from my working directory? --------------Solutions------------- Go to

  • Is it impossible to perform initialization before calling a superclass's constructor? 2009-01-14

    I'd like for a subclass of a certain superclass with certain constructor parameters to load an XML file containing information that I'd then like to pass to the superconstructor. Is this impossible to achieve? --------------Solutions------------- How

  • NHibernate - how to enforce uniquenes? 2009-06-19

    My scenario is as follows: I have some objects (Messages) that can be tagged So I have a Tag entity and many-to-many relationship The above is done and working Now, when tagging, I'd like to save new tags only if they don't exist (where existence is

  • Visual Studio 2008 Professional Build Process 2009-06-27

    I would like to accomplish two things during my build process: Run unit tests - I have a Test Project with my unit tests. I would like to run all of these tests on build and receive a notification if the build fails validation. Merge web.config files

  • jQuery find by inline css attribute 2009-07-24

    I need to find an element based on a specific css attribute. the css is applied inline and I can not use a class. Is there anyway to achieve this in jquery? --------------Solutions------------- You could use an attribute selector For example $(":radi

  • Calling a Lua function from another thread 2009-12-15

    In my sample application, I have basically two threads. The main thread contains a Lua engine (which is not thread-safe) and registers some C++ functions into this engine. However, one of these functions takes too long to perform (since it downloads

  • ASP.NET MVC 1.0 - Model binder for Dictionaries 2010-01-22

    I have a ViewModel class containing a Dictionary (and other irrelevant things for this question): public class MyViewModel { public Dictionary<int, string> Data { get; set; } /* ... */ } Then I have a couple of GET/POST actions that deal with t

  • What does it call in GWT to make 2 UI consistent? 2010-03-06

    I saw a video of Google I/O and found an example of GWT UI being very consistent between clients. Which you can save, add, drag and drop in almost real time between clients. I currently don't understand the basic of this (In GWT, i think it implement

  • Javascript function to add X months to a date 2010-04-24

    Is there a built in equivalent to the .NET framework's AddMonth function or VB's DateAdd function? I'm looking for the easiest, cleanest way to add X month to a Javascript date. I'd rather not handle the rolloing over of the year as done here. or hav

  • Thread-safe initialization of function-local static const objects 2010-06-02

    This question made me question a practice I had been following for years. For thread-safe initialization of function-local static const objects I protect the actual construction of the object, but not the initialization of the function-local referenc

  • How to generate unique serial number of machine in Delphi? 2010-06-05

    I have question how to generate unique serial number of machine in Delphi? I tried to do this using the ID the motherboard or processor, but unfortunately it's unfortunately supported. Partition serial numbers, etc. fall off, because it is changing a

  • python: iif or (x ? a : b) 2010-06-15

    Possible Duplicate: Python Ternary Operator If Python would support the (x ? a : b) syntax from C/C++, I would write: print paid ? ("paid: " + str(paid) + " €") : "not paid" I really don't want to have an if-check and two independent prints here (bec

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.112 (s). 11 q(s)