[Go to site: main page, start]

0% found this document useful (0 votes)
1 views2 pages

JavaScript - Document - getelementsByName Method

The document explains the JavaScript method document.getElementsByName(), which retrieves all elements with a specified name. It provides the syntax and an example that counts the total number of gender radio buttons in a form. The example demonstrates how to use this method to alert the total number of genders available in the form.

Uploaded by

Swapnil Roy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

JavaScript - Document - getelementsByName Method

The document explains the JavaScript method document.getElementsByName(), which retrieves all elements with a specified name. It provides the syntax and an example that counts the total number of gender radio buttons in a form. The example demonstrates how to use this method to alert the total number of genders available in the form.

Uploaded by

Swapnil Roy
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

8/8/23, 9:42 AM JavaScript - document.

getElementsByName() method - javatpoint

Javascript - [Link]() method


The [Link]() method returns all the element of specified name.

The syntax of the getElementsByName() method is given below:

[Link]("name")

Here, name is required.

Example of [Link]() method

In this example, we going to count total number of genders. Here, we are using
getElementsByName() method to get all the genders.

<script type="text/javascript">
function totalelements()
{
var allgenders=[Link]("gender");
alert("Total Genders:"+[Link]);
}
</script>

[Link] 2/6
8/8/23, 9:42 AM JavaScript - [Link]() method - javatpoint

<form>
Male:<input type="radio" name="gender" value="male">
Female:<input type="radio" name="gender" value="female">

<input type="button" value="Total Genders">


</form>

Output of the above example

Male: Female: Total Genders

← Prev Next →

Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

Send your Feedback to feedback@[Link]

Help Others, Please Share

[Link] 3/6

You might also like