I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery?
I can get all of them like this:
$("form :radio")
How do I know which one is selected?
I have two radio buttons and want to post the value of the selected one. How can I get the value with jQuery?
I can get all of them like this:
$("form :radio")
How do I know which one is selected?
If you only have 1 set of radio buttons on 1 form, the jQuery code is as simple as this:
What I needed to do was simplify C# code, that is do as much as possible in the front end JavaScript. I'm using a fieldset container because I'm working in DNN and it has its own form. So I can't add a form.
I need to test which text box out of 3 is being used and if it is, what's the type of search? Starts with the value, Contains the value, Exact Match of the value.
HTML:
And my JavaScript is:
Just saying any containing tag with an ID can be used. For DNNers, this is good to know. The end goal here is pass to the mid-level code what is needed to start a parts search in SQL Server.
This way I don't have to copy the much more complicated previous C# code also. The heavy lifting is being done right here.
I had to look a bit for this and then tinker with it to get it to work. So for other DNNers, hopefully this is easy to find.
try it-
To get the value of the selected
radioName
item of a form with idmyForm
:Here's an example:
Another way to get it:
I use this simple script