/    Sign up×
Community /Pin to ProfileBookmark

A singular problem in Safari :(

A BIG Hiya everyone,

I’d hate to have my first post to be in regards to a problem I need a bit of help with, but I’ve exhausted all of my ideas to fix the problem…which haven’t worked at all ?

I’m a beginner in Javascript and am teaching myself about it, so feel free to criticize everything and anything ?

Firstly, the code:

[CODE]function DoMath() {
var Adult = document.regform.Adult.value;
var AdultCost = document.regform.AdultCost.value;
var Child = document.regform.Child.value;
var ChildCost = document.regform.ChildCost.value;
var ParticipantTotal = Adult * AdultCost + Math.min(Child, 1)*ChildCost;

var Kids461 = document.regform.Kids461.value;
var Kids681 = document.regform.Kids681.value;
var Kids101 = document.regform.Kids101.value;
var Small1 = document.regform.Small1.value;
var Medium1 = document.regform.Medium1.value;
var Large1 = document.regform.Large1.value;
var XL1 = document.regform.XL1.value;
var XXL1 = document.regform.XXL1.value;
var XXXL1 = document.regform.XXXL1.value;
var Caps1 = document.regform.Caps1.value;

var Kids46 = document.regform.Kids46.value;
var Kids68 = document.regform.Kids68.value;
var Kids10 = document.regform.Kids101.value;
var Small = document.regform.Small.value;
var Medium = document.regform.Medium.value;
var Large = document.regform.Large.value;
var XL = document.regform.XL.value;
var XXL = document.regform.XXL.value;
var XXXL = document.regform.XXXL.value;
var Caps = document.regform.Caps.value;

var MerchTotal = (Kids461 * Kids46)+(Kids681 * Kids68)+(Kids101 * Kids10)+(Small * Small1)+(Medium * Medium1)+(Large * Large1)+(XL * XL1)+(XXL * XXL1)+(XXXL * XXXL1)+(Caps * Caps1);

document.regform.Participant.value = ParticipantTotal;
document.regform.Merchandise.value = MerchTotal;
document.regform.Total.value = ParticipantTotal+MerchTotal;
}
[/CODE]

It’s code to calculate the total cost of merchandise people can buy, and how much it will cost for a number of people to attend a function…but the problem is, Safari won’t either recognise or run the code. All other scripts work, like the validation of the order/registration form except the calculations script…? It’s also working in IE NN FF MO OP, but just not Safari.

The following link will take you to the page to which this code applies:
[URL=”http://three.eightblack.com/fcw/form.html”]Here’s the page![/URL]

Again, it’s only a problem within Safari and all other browsers work fine.

Thanks for listening everyone, hopefully i’ve given enough specific info for it to be useful! ?

Cheers
Nick

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@nickyangauthorMar 06.2008 — I realise the code is very amateurish, but if anyone could give me a hand it would be much appreciated ? Please let me know if more is needed to understand what the problem is.

Cheers

Nick
Copy linkTweet thisAlerts:
@SoreheadMar 06.2008 — What isnt working exaclty, what errors is Safari giving you?
Copy linkTweet thisAlerts:
@toicontienMar 06.2008 — First pitfall I see is not converting the text box values to numbers. If you type a number into a text box, JavaScript treats it as a string. The two blog posts below should get you a good grip on things:

[B]JavaScript, DOM, and the Humble FORM[/B]

[B]A Practical Guide To Numbers in JavaScript[/B]
×

Success!

Help @nickyang spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...