/    Sign up×
Community /Pin to ProfileBookmark

running a conditional when the window loads

Hello,

I am trying to run a conditional that checks the value of a field from a DB when the window loads and in turn checks or unchecks a checkbox depending on whether the value is “YES” or “NO”. I’ve tried to focus on the field within the global onload event as i have seen online, but thats not working. What could i be doing wrong?

[code]
window.onload = function() {
document.Customer.Customer_Sub.focus();
if (document.Customer.Customer_Sub.value = “” || document.Customer.Customer_Sub.value = “YES”) {
document.Customer.chkbox.checked;
document.Customer.Customer_Sub.value = “YES”;
}
}
[/code]

I have working code that changes the value of “Customer_Sub” cooresponding to the status of the checkbox (chkbox), and I am correctly reading the value in the database if there is an existing session loading the window.

My problem lies with tying it to the checkbox as well as making it default to checked and “YES”, all when the window loads.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@LogicianAug 16.2006 — Hello,

I am trying to run a conditional that checks the value of a field from a DB when the window loads and in turn checks or unchecks a checkbox depending on whether the value is "YES" or "NO". I've tried to focus on the field within the global onload event as i have seen online, but thats not working. What could i be doing wrong?

[code]
if (document.Customer.Customer_Sub.value = "" || document.Customer.Customer_Sub.value = "YES")[/QUOTE]

Use the equality operator: ==
×

Success!

Help @Gazthrak 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.28,
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,
)...