I am new to javascript, and just started to taste the beauty of this language. Till now I was afraid touching this subject with the vision that since many people can't see javascript, there's no point learning this. It seems that my state of mind is changing now, as now I don't see any reason why I shouldn't make something for 98% of the population just because 2% can't get it.
So here I am. A couple of days ago gits helped me to sort out a lengthy (?) 30 line javascript code. Here, I was trying to make something different, but is in a mess. Don't know what's going wrong, as firefox is now showing any error.
Expand|Select|Wrap|Line Numbers
- // my form
- <input type="text" size="4" maxlength="4" name="echantillon" id="echantillon" value="" /> <input type="button" class="button" value="Je valide" onclick="recalculateAchat('echantillon');" />
Expand|Select|Wrap|Line Numbers
- // my function
- function recalculateAchat(id) {
- var achatArray = new Array();
- achatArray['REC1'] = 5;
- achatArray['REC2'] = 10;
- box = document.getElementById(id);
- var discount = box.value;
- for(remise in achatArray){
- if (remise == discount) {
- var value = achatArray[remise];
- getAjax('achat.php','achat','exact',value,'','','');
- break;
- }
- }
- }
[php]
$carteTotal = ($exact!='') ? $carteTotal - $exact : $carteTotal;
[/php]
For some reason nothing is happening as I click on the button. Normally, it should reload a div with new $careTotal value.
Any foresight ? Can anyone help me with some tips ... :)
Thanks.