Forum-webmaster
Technique - programmation => Javascript / DOM / Ajax => Message commencé par: FER24 le le 23-05-2011 a 20:28:59

Titre: Je vous demande votre avis
Posté par: FER24 le le 23-05-2011 a 20:28:59

Bonsoir,
J´ai repris la gestion du site d´un club.
Pour participer aux activités il existe un formulaire d´inscription qui calcule automatiquement le prix à payer.
Ce calcul s´effectue très bien avec internet explorer par contre avec firefox et google chrome les calculs ne se font pas.
Je suis incapable de voir où est l´incompatibilité.
Je copie ci-dessous une partie des sources.
<input type="text" name="Inscription" size="3" value="0" priorval="0" price="6.00" onchange="this.form.total.value=checkchoice(this);">

Et voici la routine de calcul qui ne fonctionne que avec internet explorer:

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkchoice(whichbox) {
with (whichbox.form) {
if (isNaN(whichbox.value)) {
whichbox.value = whichbox.priorval;
whichbox.focus();
}
whichbox.value = Math.abs(whichbox.value);
var dec = whichbox.value.indexOf('.', 1);
if (dec > 0) {
alert('Un nombre entier SVP pour \"' +whichbox.name +'\" !');
whichbox.value = whichbox.priorval;
whichbox.focus();
}
hiddentotal.value = eval(hiddentotal.value) - eval(whichbox.price * whichbox.priorval);
whichbox.priorval = whichbox.value;
hiddentotal.value = eval(hiddentotal.value) + eval(whichbox.price * whichbox.value);
return(formatcurrency(hiddentotal.value));
}
}
function formatcurrency(num) {

num = num.toString().replace(/\€|\,/g,'');
if(isNaN(num)) num = "0";
cents = Math.floor((num * 100 + 0.5) % 100);
num = Math.floor((num * 100 + 0.5) / 100).toString();
if(cents < 10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
num = num.substring(0,num.length - (4 * i + 3))+' '+num.substring(num.length-(4 * i + 3));
return (num + "," + cents +" Euros");
}
function InitForm() {
document.myform.total.value = '0';
document.myform.hiddentotal.value = 0;
for (xx = 9; xx < document.myform.elements.length; xx++) {      
/*<!-- chiffre 9 a modifier suivant Nbre de champs -->*/
if (document.myform.elements[xx].type == 'text') {
document.myform.elements[xx].value = "";
}
}
}
// End -->
</script>
Je vous remercie à l´avance pour votre avis

Titre: Re:Je vous demande votre avis
Posté par: outil-seo le le 30-05-2011 a 23:00:42

Bonjour,

Tout d'abord cela serait bien d'avoir le lien de ton site ...

Ensuite pour contourner ton probleme car je ne suis pas expert en javascript, il serait possible de réaliser la moulinette de calcul en PHP

Je reste à ta disposition pour cela.

A toi de voir ...

Bon courage


Forum-webmaster | Actionné par YaBB SE
© 2001-2003, YaBB SE Dev Team. Tous droits réservés.