/    Sign up×
Community /Pin to ProfileBookmark

Really need some check box help-Please???

I have some Javascript code that when I pass the form to a function, all of the checkboxes become checked automatically, even if they were not checked. This happens after an alert box reminding the user to not leave info out of form. Plleeaassee, any help would be greatly, greatly appreciated. Thanks. I attached my code.

[upl-file uuid=f894dd77-ab8e-4a47-9e04-f2ab854a35db size=6kB]rent1a.txt[/upl-file]

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@Dan_DrillichMar 12.2003 — <i>
</i>if((document.rentalForm.checkPlates.checked=true) || (document.rentalForm.checkSilverware.checked=true) || (document.rentalForm.checkGlasses.checked=true))
{
if(document.rentalForm.checkPlates.checked=true) .......



Please replace all over = with == ?
Copy linkTweet thisAlerts:
@pyroMar 12.2003 — First to tell you why your checkboxes were automatically checking themselves...

In your if statements you had single ='s rather than the comparison operative, a double ==. ?

Secondly, you may want to change a few things.

Up near the top of your script, you have this (minus your extrenous comments):

numAtt=parseInt(document.rentalForm.itemQuantity.value);

if(!(isNaN(numAtt)) &amp;&amp; (numAtt&gt;0) &amp;&amp; (numAtt!=""))


It is a bit easier to use a RegExp, like this:

if (/[1-9]/.test(document.rentalForm.itemQuantity.value))I hate to say it but that whole scirpt has a lot of extrenous coding in it... :p
Copy linkTweet thisAlerts:
@pyroMar 12.2003 — Oops. Didn't see that you replied, Dan. I hit post reply, and then when and did a few things. When I came back, I posted my answer...and saw that you had already anwered... :p
Copy linkTweet thisAlerts:
@krazyspurauthorMar 12.2003 — Thnaks guys. Like I said, I'm still a newbie. My professor wants the isNaN statements. I am just having a hard time gripping it. You guys made it easier. Thanks, again.
Copy linkTweet thisAlerts:
@pyroMar 12.2003 — Well, tell your professor... j/k. ?
Copy linkTweet thisAlerts:
@krazyspurauthorMar 12.2003 — That's cool. She is a b**** sometimes. She has been programming for years, and we have a really crappy book. I'm gonna get a better reference, and, obviously, I'm using the web. I really wanted to thank you guys again. I got it working flawlessly. I cleaned it up a bunch.
×

Success!

Help @krazyspur 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.17,
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,
)...