Calculation process between two...

User 2611054 Photo


Registered User
33 posts

Hi Eric,

First of all thank you very much for your help.

And thanks god to have you :)

I uploaded the form to my hosting and it's working fine.

But i get complain because of dicimal numbers this against our sells policy.

I know i make it difficult before but now if you could please edit the cod and make both of results 1 & 2 Roundup the results.

I know the function on XLS called Roundup nearest whole number 0 num_digits



User 187934 Photo


Senior Advisor
19,133 posts

Try this.
Always rounding values up to nearest whole integer.
Ver. 3
<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 3
jQ("#item3").css("display", "none");
jQ("#item4").css("display", "none");
jQ("input[name='fild1'],input[name='fild2']").keyup(function(){
var fild1 = parseFloat(jQ("input[name='fild1']").val());
var fild2 = parseFloat(jQ("input[name='fild2']").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*0.05) <=8){
result2 = Math.ceil(8/0.375);
}
else{
result2 = Math.ceil((fild1*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 Erice ,
thank you Very much .
i appreciate your help
User 2611054 Photo


Registered User
33 posts

Hi Erice ,

I have Update :) need ver : 4 :)

I would like to add new Feild = feild3

result1 will not affected with feild 3

only result2 will be same math the only Different is make feild1+feild3.

i traed to use your previos cod after edite but it dosent work with me

<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 3
jQ("#item3").css("display", "none");
jQ("#item4").css("display", "none");
jQ("input[name='fild1'],input[name='fild2']").keyup(function(){
var fild1 = parseFloat(jQ("input[name='fild1']").val());
var fild2 = parseFloat(jQ("input[name='fild2']").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)*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>
User 2611054 Photo


Registered User
33 posts

:rolleyes:
User 187934 Photo


Senior Advisor
19,133 posts

Ver. 4
<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) && jQ.isNumeric(fild3) && fild1 !='' && fild2 != '' && fild3 != '' ){
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

User 187934 Photo


Senior Advisor
19,133 posts

Try repasting the code above into your form.
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

User 2611054 Photo


Registered User
33 posts

Hi ,
I know the problem now.
the form working fine only when i make fild3 empty or 0 it doesn't give results .
i thought it's not working.
anyway coud you make field3 not reqaird , means if embty or 0 the form have to finish The calculation without value filde3.


fild3 not always have value some times in some cases items will be witheout this value .

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.