Jump to content
php.lv forumi
  • 0

Kā pareizi skaitīt naudu?


EdgarsK

Question

Sveiki

 

Man ir radusies neliela problēmiņa saskaitot naudu.

 

<input type="radio" onclick="cad0(this.value);" value="Ls">
<input type="radio" onclick="cad0(this.value);" value="Eur">

<script type="text/javascript">
function cad0(val) {
 switch(val) {
  case "Ls": money="0.75"; break;
  case "Eur": money="0.55"; break;
 }
 // ir 5 vertibas pa 1 uz augšu
 price2 = money * 2;
 price3 = money * 3;
 price4 = money * 4;
 price5 = money * 5;
 saveinhtml('jdx-15-23-92',price);
 saveinhtml('jdx-15-23-93',price2);
 saveinhtml('jdx-15-23-94',price3);
 saveinhtml('jdx-15-23-95',price4);
 saveinhtml('jdx-15-23-96',price5);
}
</script>

 

problēma ir sekojoša, ka javascript sareikina teiksim 0.521521 vai kautko tādu, bet jalietoju Math.Round tad attiecīgi paliek tikai 1 skaitlis.

ka pareizi reikinat lai attiecigi javascriptaa

price = 0,75

price2 buutu 1,50

price3 buutu 2,25

price4 buutu 3,00

price5 buutu 3,75

 

? paldies jau ieprieksh

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...