Javascript checkbox onChange

后端 未结 10 1215
孤街浪徒
孤街浪徒 2020-11-28 06:00

I have a checkbox in a form and I\'d like it to work according to following scenario:

  • if someone checks it, the value of a textfield (totalCost)
10条回答
  •  借酒劲吻你
    2020-11-28 06:40

    function calc()
    {
      if (document.getElementById('xxx').checked) 
      {
          document.getElementById('totalCost').value = 10;
      } else {
          calculate();
      }
    }
    

    HTML

    
    

提交回复
热议问题