hello all,

i have this code

<script type="text/JavaScript">

function checkbox_click (number)
{
   
 
alert("number is" + number);


    
}
</script>
echo "<input type=\"checkbox\" name=\"boxname\" " value=\"5\" onClick=\"checkbox_click('3');\" /> \n";

i want add more code in javascript
when is check show me in input text the number and when i check mutlti box's is + all number and when i uncheck box is - the number


please help me
thanks

Recommended Answers

All 4 Replies

i have create this code but not work 100% :(


please can you update it
html

<script  type="text/javascript"> 
 function toogle(element,id){

 var c = id; 
  c = id;

  if(element.checked) 
  { 
  c =  parseInt(document.getElementById('hel').value, 10) + c; 
  }
   else
  { 
  c =  parseInt(document.getElementById('hel').value, 10) - c; 
  }

    document.getElementById('hel').value= c; 
       } 

  </script> 
  
   <form name="orderForm">
   
     Prix 1:<input name="a" type="checkbox" value="1" onclick="toogle(this,'3')">
     <br /> 
      Prix 2: <input name="c" type="checkbox"  id="hello" value="10" onclick="toogle(this,'5')"/>       
      <br />
        <input name="d" type="text" id="hel"  value="0" readonly=""/>
        <br /> 
         </form>
Member Avatar for rajarajan2017

Just change as below for all c's

c =  parseInt(document.getElementById('hel').value) + eval(c);

thanks for help

i have done :)

Member Avatar for rajarajan2017

Please mark as solved if it is solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.