I have firstName
text that I want to change his value but it not work -
<input type="text" name="firstName" />
<script LANGUAGE="JavaScript" TYPE="text/javascript">
document.getElementsByName("firstName").[0].value = "New Value " ;
</script>
How can I change this value ?
The getElementsByName() method of the Document object returns a NodeList Collection of elements with a given name attribute in the document.
How it works: First, select the submit button by its id btnRate using the getElementById() method. Second, listen to the click event of the submit button. Third, get all the radio buttons using the getElementsByName() and show the selected value in the output element.
The difference is that GetElementByID() will retrieve a single element object based on the unique id specified, whereas GetElementsByTagName() will retrieve an array of all element objects with the specified tag name. Then you can obtain the value using GetElementById from your C++ code.
The getElementsByName() method returns a collection of elements with a specified name. The getElementsByName() method returns a live NodeList.
That's not syntactically valid JS. Remove the extra .
:
// ↓↓
document.getElementsByName("firstName")[0].value = "New Value " ;
// ↑↑
and the rest will work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With