Math Functions - Post ID 276087

User 2140875 Photo


Registered User
290 posts

Luc and Eric,

This thread has helped with a t-shirt order form I have been working on. I took the script that Eric wrote and adapted it to my form. Luc's form has two fields that are entered and then totaled. The changed script works great for the first two fields of the t-shirt order form.

But, I know nothing about java script. So, try as I might, I have not been able to get the form to work for the other 4 fields I need calculations on. Every time I try to duplicate the script then add another section and change the variable names to match my other four fields, everything stops working.

Eric, would you be willing to take a look at it. I would sure appreciate it.

I've attached the fb file, just renamed it with .txt so I could upload it, if you have a chance to look at it. Thank you very much!!!
Attachments:
User 187934 Photo


Senior Advisor
18,023 posts

Your attachment seems to be corrupt.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/
User 2140875 Photo


Registered User
290 posts

I'll put it a zip format and try again. Also, here is the script:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript">var jQ = $.noConflict(true);
jQ(document).ready(function(){
jQ("textarea[name='textinfo']").css({
'font-weight' : 'bold',
'font-size' : '14px',
'color' : 'black',
'width': '80%'
});

jQ("input[name='text77'], input[name='text78']").keyup(function(){
var MijnNaam = jQ("input[name='text3']").val();
var valone = jQ("input[name='text77']").val();
var valtwo = 12;
if(jQ.isNumeric(valone)){
var totalv = (valone * valtwo);


jQ("input[name='text74']").val(totalv.toFixed(2));
}

var valeen = jQ("input[name='text78']").val();
var valtwee = 12;
if(jQ.isNumeric(valeen)){
var totalk = (valeen * valtwee);
jQ("input[name='text75']").val(totalk.toFixed(2));

}
totalv = totalv || 0
totalk = totalk || 0

MijnNaam = MijnNaam || ""
var Total = parseInt(totalv) + parseInt(totalk) ;
jQ("textarea[name='textinfo']").val('');
jQ("textarea[name='textinfo']").val("Your total order is: $" + Total.toFixed(2));
});
});</script>

Thanks for taking your time to look at this.
Attachments:
User 187934 Photo


Senior Advisor
18,023 posts

Your script is only targeting two inputs The same as I built it for Luc.
It really helps if you name your variables something so you know what your targeting.
I redid this for ya up to your large size. I think you can figure the rest with the adjustments.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
var jQ = $.noConflict(true);
jQ(document).ready(function(){
jQ("textarea[name='textinfo']").css({
'font-weight' : 'bold',
'font-size' : '14px',
'color' : 'black',
'width': '80%'
});

jQ("input[name^='text']").keyup(function(){
var Qu_Smal = jQ("input[name='text77']").val();
var Cost_Smal = 12;
if(jQ.isNumeric(Qu_Smal)){
var total_Smal = (Qu_Smal * Cost_Smal);
jQ("input[name='text74']").val(total_Smal.toFixed(2));
}

var Qu_Med = jQ("input[name='text78']").val();
var Cost_Med = 12;
if(jQ.isNumeric(Qu_Med)){
var total_Med = (Qu_Med * Cost_Med);
jQ("input[name='text75']").val(total_Med.toFixed(2));

}

var Qu_Lar = jQ("input[name='text24']").val();
var Cost_Lar = 12;
if(jQ.isNumeric(Qu_Lar)){
var total_Lar = (Qu_Lar * Cost_Lar);
jQ("input[name='text25']").val(total_Lar.toFixed(2));

}
// Add more input codes here




total_Smal = total_Smal || 0
total_Med = total_Med || 0
total_Lar = total_Lar || 0
//Add more var here as you add input code

var Total = parseInt(total_Smal) + parseInt(total_Med) + parseInt(total_Lar) ;// Add more var here as you add them
jQ("textarea[name='textinfo']").val('');
jQ("textarea[name='textinfo']").val("Your total order is: $" + Total.toFixed(2));
});
});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/
User 2140875 Photo


Registered User
290 posts

Eric,

Thanks so much. Copied your format, added to the script 3 more sizes and everything is working fine.
Don't know what this forum would be like without you.

Again, thank you very much!

Galen
User 187934 Photo


Senior Advisor
18,023 posts

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

Here's my S-Drive site with
examples of what can be accomplished in VSD.
http://progrower.coffeecup.com/
Here's my CoffeeCup SCCP Shop with examples of what can be done.
http://progrower.coffeecup.com/shop/
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 personnel site used for testing and as an easy way to share photos.(RLM imported to RSD)
http://ericrohloff.com
http://ericrohloff.com/property/

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.