Calculation process between two...

User 187934 Photo


Senior Advisor
19,126 posts
Online Now

Perhaps.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>var jQ = $.noConflict(true);
jQ(document).ready(function(){
// ver 4
jQ("#item3").css("display", "none");
jQ("#item4").css("display", "none");
jQ("input[name='fild1'],input[name='fild2'],input[name='fild3']").change(function(){
var fild1 = parseFloat(jQ("input[name='fild1']").val());
var fild2 = parseFloat(jQ("input[name='fild2']").val());
var fild3 = parseFloat(jQ("input[name='fild3']").val());
if(jQ.isNumeric(fild1) && jQ.isNumeric(fild2) && fild1 !='' && fild2 != '' ){
var result1 = Math.ceil(((fild1+fild2 )-(fild1*0.04))/0.375);
var result2 = 0;
jQ("input[name='result1']").val(result1);
if((fild1+fild3) <=8){
result2 = Math.ceil(8/0.375);
}
else{
result2 = Math.ceil(fild1+fild3);
}
jQ("input[name='result1']").val(result1);
jQ("input[name='result2']").val(result2);
alert('Ver. 4\n Result 1 = '+result1+'\n Result 2 = '+result2);
}
else{
jQ("input[name='result1']").val('');
jQ("input[name='result2']").val('');
}
});
});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2611054 Photo


Registered User
33 posts

with this cod the result2 when fild3 empty result give NAN result.

i do screenshoot

I would like if field3 empty the calculation most be same Ver.3 of the cod.

if fild3 not empty make form calculat same ver.4
:
Attachments:
User 187934 Photo


Senior Advisor
19,126 posts
Online Now

Give this a try. This allows fild3 to be empty.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>var jQ = $.noConflict(true);
jQ(document).ready(function(){
// ver 4
//jQ("#item24").css("display", "none");
//jQ("#item25").css("display", "none");
jQ("input[name='fild1'],input[name='fild2'],input[name='fild3']").change(function(){
var fild1 = parseFloat(jQ("input[name='fild1']").val());
var fild2 = parseFloat(jQ("input[name='fild2']").val());
var fild3 = parseFloat(jQ("input[name='fild3']").val());
if(fild3 == 0 || fild3 == '' || isNaN(fild3)){
var fild3 = 0;

}
if(jQ.isNumeric(fild1) && jQ.isNumeric(fild2) && fild1 !='' && fild2 != '' ){
var result1 = Math.ceil(((fild1+fild2 )-(fild1*0.04))/0.375);
var result2 = 0;

jQ("input[name='result1']").val(result1);
if((fild1+fild3) <=8){
result2 = Math.ceil(8/0.375);
}
else{
result2 = Math.ceil(fild1+fild3);
}
jQ("input[name='result1']").val(result1);
jQ("input[name='result2']").val(result2);

}
else{
jQ("input[name='result1']").val('');
jQ("input[name='result2']").val('');
}
});
});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2611054 Photo


Registered User
33 posts


result2 need last modfi in cod

if (fild1+fild3) *0.05) <=8)
result2 :((8/0.375)* 100) / 100;
else
result2 = Math.floor(((fild1 + fild3) *0.05)/0.375)* 100) / 100;

in same time fild 3 can be empty
User 187934 Photo


Senior Advisor
19,126 posts
Online Now

Ver. 5
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
jQ(document).ready(function(){
// ver 5
//jQ("#item24").css("display", "none");
//jQ("#item25").css("display", "none");
jQ("input[name='fild1'],input[name='fild2'],input[name='fild3']").change(function(){
var fild1 = parseFloat(jQ("input[name='fild1']").val());
var fild2 = parseFloat(jQ("input[name='fild2']").val());
var fild3 = parseFloat(jQ("input[name='fild3']").val());
if(fild3 == 0 || fild3 == '' || isNaN(fild3)){
var fild3 = 0;

}
if(jQ.isNumeric(fild1) && jQ.isNumeric(fild2) && fild1 !='' && fild2 != '' ){
var result1 = Math.ceil(((fild1+fild2 )-(fild1*0.04))/0.375);
var result2 = 0;

jQ("input[name='result1']").val(result1);
if(((fild1+fild3)*0.05) <=8){
result2 = Math.floor((8/0.375)* 100) / 100;
}
else{
result2 = Math.floor((((fild1 + fild3) *0.05)/0.375)* 100) / 100;
}
jQ("input[name='result1']").val(result1);
jQ("input[name='result2']").val(result2);
}
else{
jQ("input[name='result1']").val('');
jQ("input[name='result2']").val('');
}
});
});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2611054 Photo


Registered User
33 posts

hi

This is working fine but the result 2 not rounding up the value
User 187934 Photo


Senior Advisor
19,126 posts
Online Now

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
jQ(document).ready(function(){
// ver 5
//jQ("#item24").css("display", "none");
//jQ("#item25").css("display", "none");
jQ("input[name='fild1'],input[name='fild2'],input[name='fild3']").change(function(){
var fild1 = parseFloat(jQ("input[name='fild1']").val());
var fild2 = parseFloat(jQ("input[name='fild2']").val());
var fild3 = parseFloat(jQ("input[name='fild3']").val());
if(fild3 == 0 || fild3 == '' || isNaN(fild3)){
var fild3 = 0;

}
if(jQ.isNumeric(fild1) && jQ.isNumeric(fild2) && fild1 !='' && fild2 != '' ){
var result1 = Math.ceil(((fild1+fild2 )-(fild1*0.04))/0.375);
var result2 = 0;

jQ("input[name='result1']").val(result1);
if(((fild1+fild3)*0.05) <=8){
result2 = Math.ceil(8/0.375);
}
else{
result2 = Math.ceil(((fild1 + fild3) *0.05)/0.375);
}
jQ("input[name='result1']").val(result1);
jQ("input[name='result2']").val(result2);
}
else{
jQ("input[name='result1']").val('');
jQ("input[name='result2']").val('');
}
});
});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2611054 Photo


Registered User
33 posts

Dear Eric ,

Thank you for your help you make my work easier .
User 187934 Photo


Senior Advisor
19,126 posts
Online Now

Your welcome. Have fun with your new discovery.;)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.