J
Jake Barnes
Imagine I've this block of HTML:
<p>Alex Schein Mailing List <input type="checkbox"
name="newslettersToUse[]" value="133156"> (<a href="mcControlPanel.php"
onClick="hideOrShowDivById('emailList133156'); return false;">See
emails?</a>)</p>
<form method="post" action="mcControlPanel.php"
id="emailList133156" style="display:none;"><textarea
name="formInputs[cbModifier19]">[email protected],
(e-mail address removed), (e-mail address removed),
(e-mail address removed)</textarea>
<input type="submit" value="Edit List">
<input type="hidden" name="choiceMade"
value="standardUpdate">
<input type="hidden" name="formInputs[cbId]"
value="133156">
</form>
and imagine I've this javascript function:
function hideOrShowDivById(optionDivId) {
if (document.getElementById(optionDivId)) {
var optionDiv = document.getElementById(optionDivId);
if (optionDiv.style.display == 'block') {
optionDiv.style.display='none';
} else {
optionDiv.style.height='auto';
optionDiv.style.display='block';
optionDiv.style.visibility='visible';
}
} else {
alert("There was no item on the page called " + optionDivId);
}
}
Why would I keep getting the alert "There was no item on the page"?
The HTML block above is the first item in a list of 8. For some reason,
it is visible, despite display being set to "none". The other 7 items
are invisibile, as you'd expect. And the above Javascript function
works fine on the other 7 items.
What am I missing?
<p>Alex Schein Mailing List <input type="checkbox"
name="newslettersToUse[]" value="133156"> (<a href="mcControlPanel.php"
onClick="hideOrShowDivById('emailList133156'); return false;">See
emails?</a>)</p>
<form method="post" action="mcControlPanel.php"
id="emailList133156" style="display:none;"><textarea
name="formInputs[cbModifier19]">[email protected],
(e-mail address removed), (e-mail address removed),
(e-mail address removed)</textarea>
<input type="submit" value="Edit List">
<input type="hidden" name="choiceMade"
value="standardUpdate">
<input type="hidden" name="formInputs[cbId]"
value="133156">
</form>
and imagine I've this javascript function:
function hideOrShowDivById(optionDivId) {
if (document.getElementById(optionDivId)) {
var optionDiv = document.getElementById(optionDivId);
if (optionDiv.style.display == 'block') {
optionDiv.style.display='none';
} else {
optionDiv.style.height='auto';
optionDiv.style.display='block';
optionDiv.style.visibility='visible';
}
} else {
alert("There was no item on the page called " + optionDivId);
}
}
Why would I keep getting the alert "There was no item on the page"?
The HTML block above is the first item in a list of 8. For some reason,
it is visible, despite display being set to "none". The other 7 items
are invisibile, as you'd expect. And the above Javascript function
works fine on the other 7 items.
What am I missing?