473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

If checkbox is checked, change a value.

Hi. I'm having this minor, but probably simple problem. I'm making a form that's calculating some numbers, the result depends on which checkboxes (box3 & box4) the user chooses and values the user puts in. However I can't get Javascript and my checkboxes to work together. When a user checks a checkbox, it's supposed
to change a value in the calculation, however all it outputs is "0on". box1 & box2 Works perfectly (They're both text-boxes).


Expand|Select|Wrap|Line Numbers
  1.  function runTotal(myForm) 
  2.    {
  3.  
  4.     var form_field1=Number(myForm.box1.value);
  5.     var form_field2=Number(myForm.box2.value * 1.005);
  6.     var form_field3=(myForm.box3.value);
  7.     var form_field4=(myForm.box4.value);
  8.  
  9.     // Nu kommer post-numre priserne ind i systemet.
  10.  
  11.     if (form_field1 == "7800")
  12.     {
  13.         var form_field1=200
  14.     }
  15.  
  16.     if (form_field1 == "7100") 
  17.     {
  18.         var form_field1=300
  19.     }
  20.  
  21.  
  22.    myForm.total.value = form_field1 + Math. ceil(form_field2) + form_field3 + form_field4;
  23.  
  24.    }
  25.    function checkIt(f){
  26.     if(f.box3.checked)
  27.     {
  28.     var form_field3=560
  29.     }
  30.     else
  31.     {
  32.     var form_field3=0
Sep 23 '11 #1
1 1966
Shenno
59
CheckBoxobject.checked will return current boolean current state..

u can use it to make anything..
Sep 23 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! How do I convert a CheckBox.Checked to an int? Regards Martin Arvidsson
6
by: AFN | last post by:
I want to click a checkbox and have a 4 line (approx) paragraph appear beneath the checkbox, pushing the rest of the page down. And when unchecking the checkbox, the paragraph should disappear...
4
by: Kevin | last post by:
Hi, I have a input with type checkbox. I want it to be automatically checked if the value from the corresponding field in the database is also checked. I tried this: <% set objdc =...
2
by: Matthew Louden | last post by:
For the following code, I dont understand why "no" never appears even I uncheck the check in the check box. Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As...
1
by: Carlos | last post by:
Hi all, I need to handle the checked change event for a radiobutton, but without the autopostback property set to true. Is that possible? The objective is to maintain the status of the same...
2
by: Andrew | last post by:
Hi, I have a problem capturing the checkboxes that are checked, I get false irrespective of wether they are checked or not. I have gone thru the sample code on this forum, but they dun seem to...
1
Fary4u
by: Fary4u | last post by:
Hi is any body know where is actual problem is coz it's look me some problem ? to insert value into the MS ACCESS DATABASE after the value is true form html <input type="checkbox"...
2
by: ahmurad | last post by:
Dear all, I am fresh php programmer. I've spent much time to solve a checkbox related null value submission problem in php platform. I want to submit 4 checkbox value. if I checked all the...
3
by: nologo | last post by:
All, Have a problem i just cant find the answer for. I'm trying to populate a colum in a SQL database. Basically the column requires a 1 or 0. I'm trying to populate this col via a c#...
1
by: febad | last post by:
Hello, I will like to change the value of a check box at runtime. I have a database with a field "multiple_print_select", which stores a value of "1" when it is checked so that the record can be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.