Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  8] [ 1]  / answers: 1 / hits: 17275  / 13 Years ago, wed, august 17, 2011, 12:00:00

I have the following script:



var before = document.getElementById('before');    
if (switchElement.value == 'single'){
for (var i=0; i < before.length; i++) {
if (before[i].id == before_label) {
before[i].innerHTML = 'Image';
break;
}
}
after.style.display = 'none';
}


and the HTML looks like:



<div id=before>
<p id=before_label> Before Image: </p>
<input type=file name=before size=40>
<input type=hidden name=MAX_FILE_SIZE value=10000000>
</div>


Was wondering why it didn't work and change the inner html to change?


More From » javascript

 Answers
18

To access the innerHTML of before_label, just access it directly:



document.getElementById('before_label').innerHTML = 'Image';

[#90576] Monday, August 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daquanmilesw

Total Points: 57
Total Questions: 102
Total Answers: 110

Location: Wallis and Futuna
Member since Sat, Aug 6, 2022
2 Years ago
daquanmilesw questions
;