[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Minor correction to code

Posted on 2014-07-11
5
Medium Priority
?
167 Views
Last Modified: 2014-07-13
On this page:
http://roofgenius.com/test6.asp
when entering numbers into the textbox and then clicking anywhere on the screen
a period and 0 are added to the end of the numbers entered (.0)
example enter 2545 the number changes to 2545.0
How can this be corrected ?
0
Comment
Question by:isnoend2001
  • 3
  • 2
5 Comments
 
LVL 21

Accepted Solution

by:
Randy Poole earned 2000 total points
ID: 40191350
     $('#in').change(function () {  // DETECT CHANGE IN THE TEXT FIELD
        
         roofAreaVal = $('#selectPitch option:selected').val(); // GET THE VALUE OF THE SELECT MENU
         var inVal = parseFloat($('#in').val());   // CONVERT THE VALUE OF THE TEXT BOX TO A FLOAT NUMBER
         inVal = inVal.toFixed(1); // USE ONLY ONE DECIMAL PLACE FOR THE  VALUE
         inVal=inVal==Int(inVal)?Int(inVal):inVal;
         $('#in').val(inVal); // SEND THE NEW NUMBER BACK TO THE FIELD TO VISUALLY SHOW THE CONVERSION
         if (!$.isNumeric(inVal)) { // DETECT IF OUR NUMBER IS NUMERIC

             clearFields(); // IF NOT NUMERIC, RUN THE CLEAR FIELDS FUNCTION (SET EVERYTHING TO BLANK)
             alert('Please enter a valid number'); //ALSO SEND AN ALERT
         } else {
             if (inVal <= 0) {  //IF IT IS NUMERIC, CHECK THAT THE NUMBER IS GREATER THAN 0

                 clearFields();  // IF NOT, CLEAR THE FIELDS 
                 alert('Please enter a positive number greater than zero');  // AND SEND THE ALERT
             } else {

                 calc(roofAreaVal);  // WE HAVE A GOOD VALUE, RUN THE FUNCTION TO MAKE THE CALCULATIONS 
             }
         }
     });

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 40191442
Thanks works perfect
0
 

Author Comment

by:isnoend2001
ID: 40193071
I had another EE coder write more code and now  the same problem has returned
i copied and pasted your code, but cannot determine where you made changes.
Can you tell me where you made corrections ?
http://roofgenius.com/test3.asp
0
 
LVL 21

Expert Comment

by:Randy Poole
ID: 40193344
inVal=inVal==Int(inVal)?Int(inVal):inVal;
0
 

Author Comment

by:isnoend2001
ID: 40193457
Thank you
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question