Questions tagged [getelementsbyname]

In JavaScript and VBScript, the getElementsByName is a function which is used to access all HTML elements with a specified name. Two different elements can be declared with same name unlike their Id which must be defined unique. Tag getElementsByName can be used for usage related problems of getElementsByName function.

Wiki:

The getElementsByName() is a JavaScript and VBScript function which can be used in web pages to accesses html elements with their specified name. The getElementsByName method is supported in all major browsers. The function getElementsByName() can be used to access more than one element because html elements can be defined with same name unlike theirIDs which should be defined unique.

Syntax usage:

document.getElementsByName('name')

Example:

<!DOCTYPE html>
<html>
<head>
   <script type="text/javascript">
      function getElements()
      {
          var x=document.getElementsByName("x");
          alert(x.length);
      }
   </script>
</head>
<body>

Cats:
  <input name="x" type="radio" value="Cats">
Dogs:
  <input name="x" type="radio" value="Dogs">
  <input type="button" onclick="getElements()" value="Elements with name 'x'?">

</body>
</html>

Tag usage:

The tag can be used for programming problems related to usage of getElementsByName function. Tag should be avoided for theoretical and opinion based questions.

Read more:

134 questions
0
votes
1 answer

IE 8 is not triggering click on input elements type button

The following JavaScript works on Chrome, FF, etc. - it triggers the corresponding button - but not on IE8: document.getElementsByName('save').item(0).click() Is there an equivalent…
0
votes
2 answers

document.getElementsByName doesn't work for me?

I'm making a script in tampermonkey, that clicks on an element automatically. The element I try to click is made like this when I inspect it in chrome: Item | Anodized…
bram
  • 99
  • 2
  • 11
0
votes
1 answer

Unable to get property of GetElementsbyTagName of undefined or null reference

Let me start by stating I am a Newb and while I have created a fair bit of html code, I am trying to move into XML and Javascipt for my own edification. That being said, I have run into a problem (which I researched and found similar issues) that…
user3147955
  • 1
  • 1
  • 2
0
votes
1 answer

VBA Grab data from webpage into variable

I am able to pass the excel values to the website and click it through vba. But it opens up another page with title "Results - Research Randomizer" and I dont know how I retrieve those values inside "Set#1". Can anyone give me some idea to retrieve…
user3051587
  • 1
  • 1
  • 2
0
votes
1 answer

Got multiple elements with getElementsByName, Changing their names gets weird results

I have a form with multiple input(text) elements with the same name Now, say I want to change their names to "val2[]". This is what I…
0
votes
1 answer

Controls in ContentPlaceHolder are not recognized by javascript document.getelementsbyname

I have a calender script in my project. For using it, I have added an image and on its onclick event I call a javascript function displayDatePicker: Calender I use a…
0
votes
4 answers

Javascript function changeImage: Issues using variables for getElementById or getElementsByName

I'm having some trouble getting my code to do what I want. I have multiple sections that I have set to toggle show/hide, and it functions correctly. However, I'm now trying to switch the images to where instead of always being static with "More,"…
0
votes
1 answer

What is the JavaScript code for validating a form, getting elements by name, with a loop?

I have read between 5 & 7 posts, have tried to play with some of the things I have read, including jQuery, but it feels as though most posts are well beyond my understanding. I have a form which will act as a data submission tool, so let's say 100…
brian-welch
  • 441
  • 1
  • 7
  • 19
0
votes
3 answers

IE10: getElementsByName() is not returning the elements that has same Id in IE10

I have table in the jsp which is dynamically populated. I used same id for all the table rows. In the javascript I want to retreive all the table row elements whose id is "resultRow". and getElementsByName("resultRow") in js gives empty…
Harish
  • 425
  • 3
  • 7
  • 19
0
votes
1 answer

selectedIndex does not work in firefox, from an array element that is

Why does this code work in IE, but not in Firefox? elems = document.forms[0].getElementsByTagName("select"); for (i = 0; i < elems.length; i++) { if (elems[i].studentid && elems[i].studentid == studid && elems[i].selectedIndex == 0) …
Fandango68
  • 4,461
  • 4
  • 39
  • 74
0
votes
4 answers

Why isn't GetElementsByTagName working in this form?

I have a form up at avidest.com/new. The first field is a radio button. Underneath the email field is a hint that should change depending on which value is selected for the radio button. If employer is selected, the hint should say "please use…
0
votes
1 answer

HTMLElement's GetAttribute("html") or GetAttribute("text") not returning a value

Using this example how can i get the "GOOGLE CLICK" on this line using C# HTMLElement's Get Attribute. assuming that this element was absorbed using getElementByTagName. I am not sure what kind of attribute to use I've tried "html" & "text" (ex.…
0
votes
2 answers

getElementsByTagName IE Issue

This code works well in all major browsers except Internet Explorer (Opera, Firefox, Crome..) Every second js issue is related to IE. Thanks in advance.