/    Sign up×
Community /Pin to ProfileBookmark

simple javascript throwing error…why?

guys,

here is my code. i cannot seem to figure out why i am getting an error thrown in IE.

[CODE]

function validateControl()
{
var counter = 0;
Control oFrm = Page.Form;
//loop through panel controls
foreach (Control oCtl in oFrm.Controls)
{
//find your control and do with it as you like here
if(oCtrl.type==”checkbox”)
{
if(oCtrl.checked)
{
counter++;
}
}
}

if(counter == 0)
{
alert(“Please check a status.”);
}
}

[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@mrhooOct 20.2008 — an identifier with a space in it (Control oFrm) will throw an error in any browser, though the browsers can be set to hide the error messages.
Copy linkTweet thisAlerts:
@ajcool123authorOct 20.2008 — so the code is not valid then? how can i write some code to loop through all checkboxes on the page and make sure they are all checked? thanks!
Copy linkTweet thisAlerts:
@ZeroKilledOct 20.2008 — i'm confused. the loop foreach is new to me. did a search on google and found that foreach loop is new in javascript 1.6 however, did internet explorer support it? also found that [b]foreach[/b] is wrote incrorrectly, is [b]for each[/b].
×

Success!

Help @ajcool123 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 5.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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...