|
|
|
|
Bonjour,
Sur ma page j'ai deux fonction javascript. Dans la deuxième fonction, j'ai besoin d'appeler la premiére.
function calculerTotal(p1){
blabla bla
blabla bla
blabla bla
}
function saisirValeur(){
bla bla bla
bla bla lba
//Appel de la 1er fonction
calculerTotal(p1);
}
Configuration: Windows Vista Firefox 2.0.0.13
Voila tout ce qu'il y a dans ma balise SCRIPT.
<script>
////////////////////////////////////////////////////////////////////////
function total(i){
//i=i-1;
total=0;
for(j=1;j<i;j++){
id='montant'+j;
//alert(document.getElementById(id).innerHTML);
total = total + parseInt(document.getElementById(id).innerHTML) ;
}
document.getElementById('montantTotal').innerHTML = total + ' €';
}
////////////////////////////////////////////////////////////////////////////
function changerFour(idFour){
document.location.href = 'creerCommandeFour.php?four='+idFour;
}
////////////////////////////////////////////////////////////////////////////
function rentrerValeur(i, type){
if(type==true){
fin = ' gr';
}else{
fin = ' ';
}
id='appro'+i;
qte=prompt("Saisir la quantité à commander","");
if(qte==null){
//Rien
}else{
document.getElementById(id).innerHTML=qte+fin;
///APPEL////
total(document.getElementById('iteration').value);
}
}
/////////////////////////////////////////////////////////////////////////////
function ajoutArticle(){
ref=document.getElementById('ref').value;
idFour=document.getElementById('idFour').value;
iteration = document.getElementById('iteration').value;
//Appeler une fonction AJAX///////////////////////////////////////////
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else {
if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else { // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
return;
}
}
//xhr_object.open("GET", "calculerPrix.php?idProd="+ref+'&grammes='+grammes,true);
xhr_object.open("GET", "ajoutLigne.php?ref="+ref+"&idFour="+idFour+"&iteration="+iteration,true);
xhr_object.send(null);
xhr_object.onreadystatechange=function(){
if(xhr_object.readyState == 4 && xhr_object.status == 200){
eval(xhr_object.responseText);
}
////////////////////////////////////////////////////////////////
}
}
</script>
|