slight adjustment to code written by another EE coder

This page:
http://roofgenius.com/test3.asp

<div id="measureLabel">* Required</div>Text turns black when the value is between 100 and 100,000
if value gets less than 100 or more than 100,000 then label will return to red

<div id="selectPitchLabel">* Required</div> Text turns black when a selection is made
Both labels to be red when the reset button is clicked

<h3 id="Result">Select Pitch</h3>
The <h3 label contains the combobox text when a selection is made. (this part is done)
this needs to be done: Clicking the reset button change the <h3 text to Select Pitch
isnoend2001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The range detection

  if (parseInt(InPutFeet,10) < 100 || parseInt(InPutFeet,10) > 100000){ // TEST IF InPutFeet IS WITHIN RANGE.Q_28474782
               $('#measureLabel').addClass('Require');
         }

Open in new window

Added here
    // THIS FUNCTION WILL RUN ALL OF OUR CALCULATIONS
     function calc(roofAreaVal) {
          // DO ALL OF OUR MATH
         InPutFeet = parseInt($('#in').val(), 10); //InPutFeet = Users input into textbox
         Multipler = parseFloat(roofAreaVal).toFixed(2); //Multipler = ComboBox selected value
         FeetToAdd = (parseInt(InPutFeet, 10) * parseFloat(Multipler)).toFixed(2); //FeetToAdd = InPutFeet * Multipler
         TotalFeet = parseInt(InPutFeet, 10) + parseFloat(FeetToAdd); //TotalFeet = InPutFeet + FeetToAdd		
         TotalSquares = TotalFeet / 100; //TotalSquares = TotalFeet / 100
       TotalSquares = parseFloat(TotalSquares).toFixed(2);
          // UPDATE OUR FIELDS
         $('#Multiplier').text(Multipler);
         $('#FeetAdded').text(FeetToAdd);
         $('#Total').text(TotalFeet);
         $('#TotalSqs').text(TotalSquares);
         if (parseInt(InPutFeet,10) < 100 || parseInt(InPutFeet,10) > 100000){ // TEST IF InPutFeet IS WITHIN RANGE.Q_28474782
               $('#measureLabel').addClass('Require');
         }
     }

 });

Open in new window

0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
><div id="selectPitchLabel">* Required</div> Text turns black when a selection is made
Both labels to be red when the reset button is clicked

// THIS FUNCTION WILL CLEAR OUT ALL OF THE FIELDS.  WE RUN THIS WHEN THERE IS AN ERROR
     function clearFields() {  
         $('#in').val('');
         $('#Multiplier').text('Na');
         $('#FeetAdded').text('Na');
         $('#Total').text('Na');
         $('#TotalSqs').text('Na');         
         $('#selectPitch').val(0); //new 07-12-14
         $('#measureLabel').addClass('Require'); // Q_28474782
         $('#selectPitchLabel').addClass('Require');//Q_28474782 
     }

Open in new window

0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
<h3 id="Result">Select Pitch</h3>
The <h3 label contains the combobox text when a selection is made. (this part is done)
this needs to be done: Clicking the reset button change the <h3 text to Select Pitch

 
 // THIS FUNCTION WILL CLEAR OUT ALL OF THE FIELDS.  WE RUN THIS WHEN THERE IS AN ERROR
     function clearFields() {  
         $('#in').val('');
         $('#Multiplier').text('Na');
         $('#FeetAdded').text('Na');
         $('#Total').text('Na');
         $('#TotalSqs').text('Na');         
         $('#selectPitch').val(0); //new 07-12-14
         $('#measureLabel').addClass('Require'); // Q_28474782
         $('#selectPitchLabel').addClass('Require');//Q_28474782 
         $('#Result').text('Select Pitch');//Q_28474782 
     }

Open in new window

0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Sample with updates

http://jsbin.com/rupal/1/
0
isnoend2001Author Commented:
Thanks Padas i tried your http://jsbin.com/rupal/1
and it calculates even if no combobox selection made
I think the range should include testing the index of the combo
 if (parseInt(InPutFeet,10) < 100 || parseInt(InPutFeet,10) > 100000){ // TEST IF InPutFeet IS WITHIN RANGE.Q_28474782
               $('#measureLabel').addClass('Require');
         }
if number  >= 100 and number  <100000 and Combobox.text <> "Select Pitch" then
do calculation
<> in vb = not
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
This will not calculate if the field is blank

http://jsbin.com/rupal/2
     // UPDATE OUR FIELDS
       if (InPutFeet){
         $('#Multiplier').text(Multipler);
         $('#FeetAdded').text(FeetToAdd);
         $('#Total').text(TotalFeet);
         $('#TotalSqs').text(TotalSquares);
         if (parseInt(InPutFeet,10) < 100 || parseInt(InPutFeet,10) > 100000){ // TEST IF InPutFeet IS WITHIN RANGE.Q_28474782
               $('#measureLabel').addClass('Require');
         }
       }
     }

Open in new window


Option 2 http://jsbin.com/rupal/3
    // UPDATE OUR FIELDS
       if (parseInt(InPutFeet,10) > 100 && parseInt(InPutFeet,10) < 100000){
         $('#Multiplier').text(Multipler);
         $('#FeetAdded').text(FeetToAdd);
         $('#Total').text(TotalFeet);
         $('#TotalSqs').text(TotalSquares);
         
       }else{
         $('#measureLabel').addClass('Require');
         
       }
     }

Open in new window


You probably want something in there that shows the value needs to be between 100 and 100,000
0
isnoend2001Author Commented:
I like that jsbin it was different i could copy the the whole page and was not trying to determine if your code goes inside a function or is stand alone
i have given more thought to the not asking for coders by name
I think EE need to have a bonus point to overcome the 500 max
In the past i have had coders get mad if they did not get an A
to overcome that and not have to explain why i always give an A
most of your answers would get a bonus some others would not
This would not From Yesterday I asked for more info this morning
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28474283.html
anyway i have not asked for the range-calculations yet
I will in another question once i get all the bugs worked out
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Well grading is open to interpretation.     If you did not get a good answer and you grade somebody a "C", you should really have tried to reach out and clarify what you wanted.  If the Expert does not come back to help, then a C is warranted.  

There are times when the Asker views their question as easy and it is not. They end up getting an answer they don't like yet multiple experts concur, "that can't be done"

I know it was not me that added
inVal=inVal==Int(inVal)?Int(inVal):inVal;

and that may have been him.  Although I think simply changing this line
  inVal = inVal.toFixed(1); // USE ONLY ONE DECIMAL PLACE FOR THE  VALUE
to
  inVal = inVal.toFixed(0); // USE ONLY ONE DECIMAL PLACE FOR THE  VALUE

would do the trick

http://jsbin.com/kacen/1/edit
var x = 1232.63432;
var y = x.toFixed(1); // USE ONLY ONE DECIMAL PLACE FOR THE  VALUE
var z = x.toFixed(0); // USE ONLY ONE DECIMAL PLACE FOR THE  VALUE

alert('y='+y +' z='+z);

Open in new window


Part of the issue is there are multiple ways to do the same thing and multiple people are not building on another's code and simply making their own probably because it is easier.  

Typically we do not write all this code and simply  help you with what you have.  As you know, you are copy and pasting what we are doing without really understanding what is anything is doing.  And ultimately you are responsible.

That is why I tried to comment as  much as I could to help make it clear.  There are also short cuts I could have taken and JS can be hard to read if you don't have comments and write the least amount of code possible.

Anyway, this code, inVal=inVal==Int(inVal)?Int(inVal):inVal; was throwing errors.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Thanks padas
I have to run a few errands will be back
0
isnoend2001Author Commented:
Thank you
looks like everything is in order
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.