girish_327
Posts: 108
|
| Posted: 06/08/2008, 10:08 AM |
|
Hello All,
I am facing very simple problem I am having 109 checkbox and textbox each textbox having some value.
All the textboxes are hidden when we check the checkbox it will be visible with his values.
When user clicks on checkbox it will show textbox and I would like to calculate the value of each textbox and show in to another textbox but when user clicks on first checkbox it show NAN when we select another checkbox then it calculate the value. Below is code I am using please HELP me how do I calculate all the checked textbox values
function show_a1() {
if(document.getElementById('adminCheckBox1').checked == true)
{
document.getElementById('admina1').value = '20';
document.getElementById('admina1').style.visibility = 'visible';
}
else
{
document.getElementById('admina1').value = '0';
document.getElementById('admina1').style.visibility = 'hidden';
}
}
function show_a2() {
if(document.getElementById('adminCheckBox2').checked == true)
{
document.getElementById('admina2').value = '10';
document.getElementById('admina2').style.visibility = 'visible';
}
else
{
document.getElementById('admina2').value = '0';
document.getElementById('admina2').style.visibility = 'hidden';
}
}
ffunction StartCalc()
{
var totalmarks = 0;
var totalmarks = parseInt(document.getElementById("admina1").value) + parseInt(document.getElementById("admina2").value);
document.getElementById("admintotal_marks").value = totalmarks;
}
HTML CODE VIEW
<input id="adminCheckBox1" onclick="show_a1();StartCalc();" type="checkbox" value="1" name="{CheckBox1_Name}" {CheckBox1:disabled} {CheckBox1} />
<input class="marks" id="admina1" maxlength="10" size="10" value="{a1}" name="{a1_Name}" />
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 06/08/2008, 11:32 AM |
|
Hi
I am thinking your problem when clicking on the first checkbox the value of the second textbox has not been initialized to 0 of some integer value. It probably is NULL on page load so the first run doing the calc creates NAN.
I suspect if you add more boxes to this code you will gat NAN until all boxes are checked.
Maybe try onload initializing all values to 0. Or if using CCS I would think you might be just able to set default value to 0 for those hidden textboxe controls.
Hope that helps.
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
girish_327
Posts: 108
|
| Posted: 06/08/2008, 10:07 PM |
|
Hello John Real,
Yes I have set the default text box value to zero in CCS Now the Checkbox Calculating the values right way.
Thanks a lot.
Girish Baraskar http://www.realestatekolhapur.com http://www.gruhashodh.com
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
|