howlingmadpanda Posted June 1, 2013 Share Posted June 1, 2013 I understand the rest of the Calculator and I know HTML + CSS, but I have no idea how to add a sqrt button, can anybody help the code is below the line where I tried is in red: <!DOCTYPE html> <html> <head> <style type="text/css"> input {text-align:center;} table {text-align:center;position:absolute;left:550px;top:150px;} body {background-color:black;} </style> </head> <body> <FORM NAME="Calc"> <TABLE BORDER=4> <TR> <TD> <INPUT TYPE="text" NAME="Input" Size="16"> <br> </td> </tr> <TR> <TD> <INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'"> <INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'"> <INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'"> <INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '"> <br> <INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'"> <INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'"> <INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'"> <INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '"> <br> <INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'"> <INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'"> <INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'"> <INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '"> <br> <INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''"> <INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'"> <INPUT TYPE="button" NAME="Enter" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)"> <INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '"> <br> <input type="button" name="sqrt" value="sqrt" OnClick="Calc.input.value += 'sqrt'"> </td> </tr> </table> </form> </p> </body> </html> Also, I am well aware of the math.sqrt(x) function Link to comment Share on other sites More sharing options...
EdEarl Posted June 1, 2013 Share Posted June 1, 2013 No one has responded to your post in several hours. I am unsure whether I can help, but will try. Are you asking how to get a square root symbol displayed by HTML? Link to comment Share on other sites More sharing options...
howlingmadpanda Posted June 1, 2013 Author Share Posted June 1, 2013 (edited) Not at all, I need to use the function in a table, and in a button. But, that would be nice to know how to add it.... Edited June 1, 2013 by howlingmadpanda Link to comment Share on other sites More sharing options...
EdEarl Posted June 1, 2013 Share Posted June 1, 2013 (edited) OK, it seems a bit too obvious, but I'll offer this as help. http://www.w3schools.com/jsref/jsref_sqrt.asp Still having difficulty understanding what you need. Edited June 1, 2013 by EdEarl Link to comment Share on other sites More sharing options...
timo Posted June 2, 2013 Share Posted June 2, 2013 You could, for a start, ask yourself why you expect taking the square root to be expressed with a "+=". The "+=", as you may notice, is mainly used in cases where a new digit is attached to the end of your input (which is not what taking a square root does). Hint: Have a closer look at "clear" and "enter". Link to comment Share on other sites More sharing options...
howlingmadpanda Posted June 2, 2013 Author Share Posted June 2, 2013 I know, I understand the Calculator and the square root function, I need a function that I can use for Onclick=function() and use the square root I have already tried several 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