/    Sign up×
Community /Pin to ProfileBookmark

Please help with Script, doesnt work with FireFox

Can any one help me with this script? It works perfect in Internet Explorer, but with FireFox it says $NaN

I dont know whats wrong.

<html>
<head>
<title>Form Total</title>

</head>
<form method=”post” action=”test” id=”theForm”>
<body>
<p>
<script type=”text/javascript”>
function total(frm) {
var tot=300;
for(var i=0; i<frm.elements.length; i++) {
if(frm.elements[i].type==”checkbox” || frm.elements[i].type==”radio”) {
if(frm.elements[i].checked) tot+=Number(frm.elements[i].value2);
}
}
document.getElementById(“totalDiv”).firstChild.data=”$”+tot;

}
</script>
</p>

<p>&nbsp;
</p>

<br>

<div><input type=”checkbox” name=”abx” value2=”50.00″ onclick=”total(this.form);”> abx +50.00</div>
<div><input type=”checkbox” name=”asss” value2=”30.00″ onclick=”total(this.form);”> asss+30.00</div>
<div><input type=”radio” name=”radio1″ value2=”-10.00″ onclick=”total(this.form);”>
wxyz -10.00</div>
<div><input type=”radio” name=”radio1″ value2=”20.00″ onclick=”total(this.form);”> asd +20.00</div>
<div><input type=”radio” name=”radio2″ value2=”11.00″ onclick=”total(this.form);”> wxyz +11.00</div>
<div><input name=”radio2″ type=”radio” onclick=”total(this.form);” value2=”12.00″ checked> asd +12.00</div>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;

<div id=”totalDiv”>Dynamic total requires Javascript</div>

</p>
<p>&nbsp;</p>
<p>

<script type=”text/javascript”>total(document.getElementById(“theForm”));</script>
<input type=”hidden” name=”merchant” value=”test”>
<input type=”hidden” name=”item_id” value=”16″>
<input type=”submit” name=”add” value=”Add to Cart”>
</p>
</body>
</html>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Orc_ScorcherJun 06.2005 — Why are you using value2 instead of value? If you insist on this, replace frm.elements[i].value2 with frm.elements[i].getAttribute("value2").
Copy linkTweet thisAlerts:
@16isgoodauthorJun 06.2005 — the reason is because i am going to use value for another thing.
Copy linkTweet thisAlerts:
@CharlesJun 06.2005 — the reason is because i am going to use value for another thing.[/QUOTE]But you're not allowed to do that and it is likely that Firefox is enforcing the restriction. From the HTML 4.01 Specification:HTML documents are constrained to conform to the HTML DTD both before and after processing any SCRIPT elements.[/quote]
×

Success!

Help @16isgood 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.25,
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,
)...