/    Sign up×
Community /Pin to ProfileBookmark

onload not working for show/hide of element

I have a radio button that is controlling the showing/hiding of a div selection table, but on the initial load, it is not showing/hiding correctly based on the value of that radio button. (see attachment below) The alert I put in the function doesn’t even occur. 😡
The radio button works properly afterward, just not the initial load.
PLEASE help, and let me know what I have wrong….

[CODE]
<html>
<head>
<script language=”JavaScript”>
function ExposeList() {
var status = document.getElementByName(‘VIOLATIONS’);
alert(“alert here”);
for(var i = 0; i < 2; i++ ) {
alert(status[i].value);
if (status[i].value == “Y”) { document.getElementById(‘ScrollCB’).style.display = “block”; }
else { document.getElementById(‘ScrollCB’).style.display = ‘none’; }
}
function YesAnswer() {
document.getElementById(‘ScrollCB’).style.display = “block”;
}
function NoAnswer() {
document.getElementById(‘ScrollCB’).style.display = ‘none’;
}
</script>
</head>

<body onload=”ExposeList();”>
.
.
.
[/CODE]

div code…

[CODE]
<input onclick=”YesAnswer()” type=”radio” ${disabled(‘VIOLATIONS’)} ${checked(‘VIOLATIONS’,row.VIOLATIONS,’Y’)} name=”VIOLATIONS” value=”Y” />Yes
<input onclick=”NoAnswer()” type=”radio” ${disabled(‘VIOLATIONS’)} ${checkeddft(‘VIOLATIONS’,row.VIOLATIONS,’N’)} name=”VIOLATIONS” value=”N” />No
<div id=”ScrollCB” OVERFLOW: auto; WIDTH: 200px; HEIGHT: 105px”>
<input id=”VSPEED” type=”checkbox” ${disabled(‘VSPEED’)} ${checked(‘VSPEED’,row.VSPEED,’X’)} name=”VSPEED” value=”X” />Excessive Speed<br />
<input id=”VTOOCLOSE” type=”checkbox” ${disabled(‘VTOOCLOSE’)} ${checked(‘VTOOCLOSE’,row.VTOOCLOSE,’X’)} name=”VTOOCLOSE” value=”X” />Follows Too Close<br />
.
.
<input id=”VOTHER” type=”checkbox” ${disabled(‘VOTHER’)} ${checked(‘VOTHER’,row.VOTHER,’X’)} name=”VOTHER” value=”X” />Other<br />
</div>

[/CODE]

[ATTACH]11095[/ATTACH]

[upl-file uuid=604a2a23-6b8f-420e-8eba-8cc9a3f27ac4 size=24kB]Driver Violations.pdf[/upl-file]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorJun 04.2008 — document.getElement[B][COLOR="Blue"]s[/COLOR][/B]ByName()

Anyway, when you present the HTML code in the Javascript or CSS forum, let us view the generated HTML, not the server-side code.

And [I]language[/I] is deprecated. Use type instead
<i>
</i>&lt;script type="text/javascript"&gt;

And use a DOCTYPE for your document.
Copy linkTweet thisAlerts:
@jordonjauthorJun 04.2008 — added the s, and that didn't fix it......?

I don't know how to view the generated HTML, sorry.... newbie...
Copy linkTweet thisAlerts:
@KorJun 04.2008 — I don't know how to view the generated HTML, sorry.... newbie...[/QUOTE]
? My word! :rolleyes:

In FireFox : View > Page Source

In IE & Opera: View > Source

Or put a link to the test page, if it is already on a server.
×

Success!

Help @jordonj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...