Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript get value by radio button name

Tags:

javascript

first of all i am a beginner in javascript, a really big beginer

Can someone give me a hint on this?

I have a form, on the form i have a radio button.

And i would like to that if the radio is set yes , it would show the value of it on another page.

And i would like to get the value by the input name

is it possible?

I'm not asking to write my code, but just an example for a start.

i was tried with this just for a test

<input type="hidden" name="the_name" value="yes">

if(the_name.element == 'yes') {
    alert('cool');
}
like image 663
Side Avatar asked Jul 15 '26 07:07

Side


2 Answers

the_name.value, not the_name.element

like image 170
AlienWebguy Avatar answered Jul 17 '26 20:07

AlienWebguy


You can use getElementsByName() for accessing the elements value via the input name. But as a standard and since it helps load off the DOM we use getElementById() instead of the name. Also you can start from here -> http://eloquentjavascript.net/

like image 43
Sojourner Avatar answered Jul 17 '26 19:07

Sojourner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!