/    Sign up×
Community /Pin to ProfileBookmark

Calling Javascript from onChange in IE8 doesnt work!??!

Hi all,

I am trying to call a JS function from an onChange parameter within a form tag, as shown below:

<input type=”text” id=”quantity1″ tabindex=”1″ maxlength=”3″ size=”5″ onchange=”recalculate(‘quantity1′,’price1′,’6’)”>

This works perfectly in FireFox but fails in IE8 with an object expected error and launches a debugger.

I have tired many variations including adding a “;” at the end, starting with “javascript:”, onchange/onChange etc and no luck. Always works in FF but not IE.

Any help would be greatly appreciated.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 29.2009 — show us the recalculate() function. Anyway, use [B]onblur[/B] insted of [B]onchange[/B]
Copy linkTweet thisAlerts:
@danjpalmerauthorMay 29.2009 — <script type="application/javascript">

<!--

function recalculate(a,b,c)

{

var price = b;

var quan = a;

var total = c;



document.getElementById(price).value = document.getElementById(quan).value * c;

document.getElementById("sumtotal").value = document.getElementById("price1").value *
1 + document.getElementById("price2").value *1 + document.getElementById("price3").value *1;

var sumt = document.getElementById("price1").value *1 + document.getElementById("price2").value *1 + document.getElementById("price3").value *1;

if (sumt<15 && sumt>0){

document.getElementById("total").value = sumt * 1 + 2.50;

}

else if (sumt==0) {

document.getElementById("total").value = 0;

}

else {

document.getElementById("total").value = sumt;

}

}

-->

</script>

I know thw JS is by no means perfect but it works. I have changed to onBlur now.
Copy linkTweet thisAlerts:
@KorMay 29.2009 — <i>
</i>&lt;script type="[COLOR="Blue"]text[/COLOR]/javascript"&gt;
×

Success!

Help @danjpalmer 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.19,
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,
)...