Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
164
rated 0 times [  169] [ 5]  / answers: 1 / hits: 166598  / 11 Years ago, wed, september 18, 2013, 12:00:00

Here is the HTML Code:



<div class=text>
<input value=true type=checkbox checked= name=copyNewAddrToBilling><label>


I want to change the value to false. Or just uncheck the checkbox. I'd like to do this in pure JavaScript, without the use of external libraries (no jQuery etc)


More From » html

 Answers
5
<html>
<body>
<input id=check1 type=checkbox checked= name=copyNewAddrToBilling>
</body>
<script language=javascript>
document.getElementById(check1).checked = true;
document.getElementById(check1).checked = false;
</script>
</html>


I have added the language attribute to the script element, but it is unnecessary because all browsers use this as a default, but it leaves no doubt what this example is showing.



If you want to use javascript to access elements, it has a very limited set of GetElement* functions. So you are going to need to get into the habit of giving every element a UNIQUE id attribute.


[#75631] Monday, September 16, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nathalieg

Total Points: 462
Total Questions: 106
Total Answers: 93

Location: Turks and Caicos Islands
Member since Tue, Mar 30, 2021
3 Years ago
;