alicoban Posted July 6, 2006 Share Posted July 6, 2006 hi i codded a basic calculator using javascript my variables named in turkishjust save as calculator.html and open your browser and see here code <html><body><table border="1" bgcolor='navy' align='center' bordercolor="#00FFFF"><tr><td ><center><form name='form1' ><input type='button' name='btn1' value=' 1 ' onClick="btn_Tik(1)"><input type='button' name='btn2' value=' 2 'onClick="btn_Tik(2)"><input type='button' name='btn3' value=' 3 'onClick="btn_Tik(3)"><br><input type='button' name='btn4' value=' 4 'onClick="btn_Tik(4)"><input type='button' name='btn5' value=' 5 'onClick="btn_Tik(5)"><input type='button' name='btn6' value=' 6 'onClick="btn_Tik(6)"><br><input type='button' name='btn7' value=' 7 'onClick="btn_Tik(7)"><input type='button' name='btn8' value=' 8 'onClick="btn_Tik(8)"><input type='button' name='btn9' value=' 9 'onClick="btn_Tik(9)"><br><input type='button' name='btnArtı' value=' + ' onClick="btn_Topla()"><input type='button' name='btn0' value=' 0 'onClick="btn_Tik(0)"><input type='button' name='btnEksi' value=' - ' onClick="btn_Cikar()"><br><input type='button' name='btnCarp' value=' / ' onClick="btn_Bol()"><input type='button' name='btnC' value=' C 'onClick="btn_Temizle()"><input type='button' name='btnBol' value=' * ' onClick="btn_Carp()"><br><input type='button' name='btnGeri' value='Back Space Key 'onClick="btn_GeriAl()"><br></td></tr> <tr><td><center><input type="textfield" name="txtSonuc" value="" size='15'></td></tr> <tr><td><center><input type="button" name='hesapla' value="Calculate" onClick ="btn_Hesapla()"></form> </td></tr> </table> <script language="JavaScript" type="text/javascript">// this is coded by alicoban debuggerfohn@gmail.comvar sayi1=0;var sayi2=0;var sonuc=0;var topla=false;var cikar=false;var bol=false;var carp=false; function btn_Tik(deger){document.form1.txtSonuc.value+=deger;}//////////////////////////////////// function btn_Temizle(){document.form1.txtSonuc.value="";topla=false;cikar=false;bol=false;carp=false;}//////////////////////////////////// function btn_GeriAl(){var deger=document.form1.txtSonuc.value;boy=deger.length;var gec="";if(boy>=1) {var i=0;for(i=0;i<boy-1;i++) // for back { gec+=deger.charAt(i); } document.form1.txtSonuc.value=gec; }}function reset(){topla=false;cikar=false;bol=false;carp=false;}////////////////////////////////////////////////////function btn_Topla(){reset();topla=true;sayi1=parseInt(document.form1.txtSonuc.value)document.form1.txtSonuc.value="";}///////////////////////////////////////////////////function btn_Cikar(){reset();cikar=true;sayi1=parseInt(document.form1.txtSonuc.value)document.form1.txtSonuc.value="";}///////////////////////////////////////////////////function btn_Carp(){reset();carp=true;sayi1=parseInt(document.form1.txtSonuc.value)document.form1.txtSonuc.value="";}///////////////////////////////////////////////////function btn_Bol(){reset();bol=true;sayi1=parseInt(document.form1.txtSonuc.value)document.form1.txtSonuc.value="";}///////////////////////////////////////////////////function btn_Hesapla(){if(topla==true) { sayi2=parseInt(document.form1.txtSonuc.value) sonuc=sayi1+sayi2; document.form1.txtSonuc.value=sonuc; topla=false; }else if(cikar==true) { sayi2=parseInt(document.form1.txtSonuc.value) sonuc=sayi1-sayi2; document.form1.txtSonuc.value=sonuc; cikar=false; } else if(carp==true) { sayi2=parseInt(document.form1.txtSonuc.value) sonuc=sayi1*sayi2; document.form1.txtSonuc.value=sonuc; carp=false; } else if(bol==true) { sayi2=parseInt(document.form1.txtSonuc.value) sonuc=sayi1/sayi2; document.form1.txtSonuc.value=sonuc; bol=false; }}///////////////////////////////////////////////</script> </body></html> Link to comment Share on other sites More sharing options...
scott100 Posted July 6, 2006 Share Posted July 6, 2006 hi i codded a basic calculator using javascript my variables named in turkish just save as calculator.html and open your browser and seeVery nice Do you have a problem with your code or are you just sharing your script with us? Link to comment Share on other sites More sharing options...
alicoban Posted July 6, 2006 Author Share Posted July 6, 2006 Very nice Do you have a problem with your code or are you just sharing your script with us?<{POST_SNAPBACK}> there is no problem. just i wanted share it.Is there any non understandable part i can explain it. Link to comment Share on other sites More sharing options...
zanfranceschi Posted July 6, 2006 Share Posted July 6, 2006 the cool thing about your calculator is that when a symbol is pressed the display is cleared. Very cool! Link to comment Share on other sites More sharing options...
chadmichael Posted July 6, 2006 Share Posted July 6, 2006 Ali,Hey, I speak some Turkish actually. Not well, but I spent three months in Turkiye and taught computer science to some high school kids in a science school Gumushane. Anyway, how do you get the button images and mouseover highlighting? I don't see this in the code. Okay, I just changed the background color and I recoginize that its just the normal buttons as styled by the browser. The navy background makes them look so different. Anyway,Cool calculator. Link to comment Share on other sites More sharing options...
smiles Posted July 7, 2006 Share Posted July 7, 2006 nice but have some problem with more than one calculation1+2+3=5 Link to comment Share on other sites More sharing options...
alicoban Posted July 7, 2006 Author Share Posted July 7, 2006 nice but have some problem with more than one calculation1+2+3=5 <{POST_SNAPBACK}> yeah i know the problems.it easy to solve it i have to write a little more code and maybe it can solve like (12*25-25)/14+36 problems and parsing the statement. when i do it i wil send Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now