html - How to get value of textboxes, textareas, and radios in the same way in Javascript? -
I need a function / code that will return the value that the user is credited for the area whose name / ID it It will not make any difference whether the field is a text box, Textera, radio or selection. For example, the area may be:
& lt; Input type = 'radio' name = 'a_21' value = 'test' id = 'a_21_0' / & gt; & Lt; Input type = 'radio' name = 'a_21' value = 'test2' id = 'a_21_1' /> or
& lt; Textarea name = "a_21" rows = "30" cols = "6" & gt; & Lt; / Textarea & gt; When I call:
getVal function ('a_21'); It should return the selected value.
How can I do this? Will:
document.myForm.field.value There is also work for curriculum, dropdown and radio?
Using jQuery, you can:
$ ( '[Name = "a_21"]'). Val (); This will give you the value of the field with a_21 name, so let's talk about what type of area.
Note: No quote is required, but I have found in the practice of adding checkbox arrays:
& Lt; Input type = "checkbox" name = "id []" value = "2" /> I think it is better than trying to know why it does not work.
Comments
Post a Comment