Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-28-2012, 05:38 PM   PM User | #1
Scott55
New to the CF scene

 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Scott55 is an unknown quantity at this point
javascript calculator input box

hey guys, I have to create a scientific calculator using javascript and I am wondering how I can make it so that the equals box (box that displays the answer) cannot be manually cleared with the mouse cursor.



thanks!

Scott
Scott55 is offline   Reply With Quote
Old 03-28-2012, 05:44 PM   PM User | #2
Nile
Regular Coder

 
Nile's Avatar
 
Join Date: Jun 2008
Posts: 280
Thanks: 2
Thanked 46 Times in 46 Posts
Nile is an unknown quantity at this point
Code:
<input type="text" disabled="true">
Nile is offline   Reply With Quote
Old 03-28-2012, 06:04 PM   PM User | #3
Scott55
New to the CF scene

 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Scott55 is an unknown quantity at this point
thanks alot! Where exactly do I put that code? - also I am trying to make the only input into the calculator from the buttons themselves

Last edited by Scott55; 03-28-2012 at 06:11 PM..
Scott55 is offline   Reply With Quote
Old 03-28-2012, 06:19 PM   PM User | #4
Nile
Regular Coder

 
Nile's Avatar
 
Join Date: Jun 2008
Posts: 280
Thanks: 2
Thanked 46 Times in 46 Posts
Nile is an unknown quantity at this point
That's the HTML to make a disabled input. If you don't know where to place something like that in the markup section of your code, you should probably learn HTML before attempting javascript.
Nile is offline   Reply With Quote
Old 03-28-2012, 09:50 PM   PM User | #5
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,447
Thanks: 0
Thanked 496 Times in 488 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by Nile View Post
Code:
<input type="text" disabled="true">
Code:
<input type="text" readonly>
would be better as then the result will not be greyed out.

Also ="true" is invalid HTML. You either specify disabled by itself to disable a field in HTML or use disabled="disabled" for XHTML.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote
Old 03-29-2012, 04:16 AM   PM User | #6
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
Quote:
Originally Posted by Scott55 View Post
also I am trying to make the only input into the calculator from the buttons themselves
You might be interested in the calculator tutorial currently linked in my signature.
__________________
.My new Javascript tutorial site: http://reallifejs.com/
.Latest article: Calculators — Tiny jQuery calculator, Full-fledged OOP calculator, Big number calculator
.Latest quick-bit: Including jQuery — Environment-aware minification and CDNs with local fallback
venegal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:47 PM.


Advertisement
Log in to turn off these ads.