| | |
setting value is not sticking
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I'm trying to make a simple calculator and whenever I want to add text to the textfield(say a number) it will show up, then will dissapear.
This is how I'm doing it, but why is the text dissapearing right after it appears?
Note: This method is called whenever one of the number buttons is clicked.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function display(number) { var x = document.form1.displayText; x.value = number; }
This is how I'm doing it, but why is the text dissapearing right after it appears?
Note: This method is called whenever one of the number buttons is clicked.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
I know, that's what I don't understand. It' almost like it's refreshing the page or something. Here's the code I've got. I know the thing looks really ugly but I'm a beginner at JavaScript:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<html><head> <title>JavaScript Calculator</title> <script language="JavaScript" type="text/javascript"> function display(number) { var x = document.form1.displayText; x.value = number; } </script> </head> <body> <form name="form1"> <table> <tr> <input type="text" name="displayText" size="30"> </tr> <tr> <td><input type="submit" value="7" name="button7" onClick="display('7')"></td> <td><input type="submit" value="8" name="button8" onClick="display(8)"></td> <td><input type="submit" value="9" name="button9" onClick="display(9)"></td> <td><input type="submit" value="/" name="buttonDivide"></td> <td><input type="submit" value="sqrt" name="buttonRoot"></td> </tr> <tr> <td><input type="submit" value="4" name="button4" onClick="display(4)"></td> <td><input type="submit" value="5" name="button5" onClick="display(5)"></td> <td><input type="submit" value="6" name="button6" onClick="display(6)"></td> <td><input type="submit" value="*" name="buttonMultiply"></td> <td><input type="submit" value="^2" name="buttonSquare"></td> </tr> <tr> <td><input type="submit" value="1" name="button1" onClick="display(1)"></td> <td><input type="submit" value="2" name="button2" onClick="display(2)"></td> <td><input type="submit" value="3" name="button3" onClick="display(3)"></td> <td><input type="submit" value="-" name="buttonMinus"></td> <td><input type="submit" value="1/x" name="buttonOneX"></td> </tr> <tr> <td><input type="submit" value="0" name="button0" onClick="display(0)"></td> <td><input type="submit" value="." name="buttonPeriod"></td> <td><input type="submit" value="+/-" name="buttonPlusOrMinus"></td> <td><input type="submit" value="+" name="buttonPlus"></td> <td><input type="submit" value="=" name="buttonEquals"></td> </tr> </table> </form> </body>
![]() |
Similar Threads
- help setting up web server (Linux Servers and Apache)
- Setting up a 2nd hard drive (Windows NT / 2000 / XP)
- newbie: need help setting up my network, router + firewall problems (Networking Hardware Configuration)
- setting up a new network (Networking Hardware Configuration)
- Video setting question (Monitors, Displays and Video Cards)
- Setting up my PC as a web server (Windows NT / 2000 / XP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Problem using onload
- Next Thread: Please i need some help with js
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxexample ajaxhelp ajaxjspservlets animate array automatically beta box browser bug calendar captchaformproblem cart close codes column cookies css date debugger decimal dependent design disablefirebug dom download element embed engine enter error events ext file firefox focus form frameworks getselection google gwt gxt hiddenvalue highlightedword hint html htmlform ie7 iframe index java javascript javascripthelp2020 jawascriptruntimeerror jquery jsp libcurl listbox maps masterpage media menu microsoft mimic mp4 onmouseoutdivproblem onmouseover paypal pdf php player position post problem programming prototype redirect regex safari scale scriptlets scroll search security select software sql text textarea toggle unicode variables w3c website window windowofwords windowsxp






