Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
using javascript to get a value from a checkbox
Old 02-11-2010, 02:57 PM using javascript to get a value from a checkbox
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 312
Name: Jason Eyermann
Location: england bristol
Trades: 0
PROBLEM NOW SOLVED

I'm just trying to get a value from a checkbox with javascript for a price for an automatic price calculator.

-------
eg-<input type="checkbox" id="advert01" name="advert01" value="yes">


--------
I tried getting the value a number of ways but doesn't seem to work

i've tried - var checkboxValue = document.formname.advert.value

also

if (document.formname.advert.checked) {
checkboxValue = "300";
} else {
checkboxValue = "10";
}

but the value always comes up as 10. I also tried the ischecked function.

I've search google. can't find anything. I lost an hour today at work trying to sort this out. I've already got the info from about 50 text fields and 10 dropdowns. I just can't do it for the check box.

Can anyone enlighten me.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by jason_bristol; 02-12-2010 at 12:45 PM..
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
 
Register now for full access!
Old 02-11-2010, 04:32 PM Re: using javascript to get a value from a checkbox
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
document.formname.advert.checked
have you tried using

Code:
document.formname.advert01.checked
????
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 02-11-2010, 06:14 PM Re: using javascript to get a value from a checkbox
jason_bristol's Avatar
Ultra Talker

Latest Blog Post:
New site - ConnectFrench.com
Posts: 312
Name: Jason Eyermann
Location: england bristol
Trades: 0
yes. I had ment to write document.formname.advert01.checked


I was being really stupid. - PROBLEM NOW SOLVED
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by jason_bristol; 02-12-2010 at 12:45 PM..
jason_bristol is offline
Reply With Quote
View Public Profile Visit jason_bristol's homepage!
 
Reply     « Reply to using javascript to get a value from a checkbox
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31858 seconds with 12 queries