-2

Hi i'm new to JS and i'm trying to do a BMI(Body/Mass Index) calculator for my website.

What i want to do is when a user clicks to Temizle(Reset) button disabled checkbox should be usable again. I wrote a function which is called "temizle" but it didn't work. I want to know 2 things for the solution.

  1. If there is a easy way to do what i ask, please tell me.
  2. If there is not, how should i change my code?
 <html>
        <head>
        <script language="JavaScript">
        <!--
        function temizle(){
    if(document.getElementById('e').disable=true)
    {                       
    document.getElementById('e').disable=false                                                          
    }
    if(document.getElementById('k').disable=true) 
    {
    document.getElementById('k').disable=false
     } 
    }
    //-->
    </script>
    </head>
    <body>
    <form name="bmiForm">
    Cinsiyetiniz: Erkek<input type="checkbox" id="e" name="erkek" onclick="if (this.checked) document.getElementById('k').disabled=true; else document.getElementById('k').disabled = false;"/> Kadın<input type="checkbox" id="k" name="kadın" onclick="if (this.checked) document.getElementById('e').disabled=true; else   document.getElementById('e').disabled = false;"/><br />  
  Kilonuz(kg): <input type="text" name="kilo" size="10" /> Örn:75<br />
  Boyunuz(cm): <input type="text" name="boy" size="10" /> Örn:183<br />
  <input type="button" value="Kütle/Vücut İndeksi Hesapla" onClick="bmihesaplama()" /><br />
  Kütle/Vücut İndeksiniz(BMI): <input type="text" name="bmi" size="10" /><br />
  Bunun Anlamı: <input type="text" name="sonuc" size="45" /><br />
  <input type="reset" value="Temizle" onclick="temizle()" />
  </form>
    </body>
    </html> 

Thx for your help.

KF2
  • 9,887
  • 8
  • 44
  • 77

1 Answers1

2

You've typed disable as the property, but it's disabled. You need to change that; it's important.

if(document.getElementById('k').disable=true) 

Should also be changed; this is an assignment. You could use ==, but you can also just do:

if (document.getElementById('k').disabled) 

http://jsfiddle.net/ExplosionPIlls/3AMtG/2/

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405