Jump to content
php.lv forumi

help! multiplay iespējams


saintdevi

Recommended Posts

Ideja tāda, man ir neliels ishopiņš, bet nepieciešama ailīte (pie groza pārskata kkur) kurā pircējs var ierakstīt atlaidi procentos un viņam vnk parādās summa ar atlaidi ... Domāju ka to var izdarīt ar js! Cena nāk no db ar simbolu:

Piemērs:

 

Preču cena : Ls32.55

Atlaide : [inputiņš kurā ieraksta % atlaidi piem 10%]

Cena ar atlaidi : 29.30

Piegāde : Ls5.00

Kopā : 37.55

 

Vai ir iespējams kko tādu uztaisīt ar JS, tā cena nekur nav jānosūta, tik lai pircējs redz, kāda ir summa ar atlaidi!

Ja ira, varbūt varētu palūgt kādu piemēriņu? Lūdzu :)

Link to comment
Share on other sites

kaut ka ta? Algebrisko pusi gan jau var uztaisit labak uz fikso.

 

ps. nemaz nezinaju ka ieksh JS Math.round(x) nevar padot precizitati O_o

 

<script text="text/javascript">
$ = function(id) { return document.getElementById(id); }

function cntprice(){
var price = $('price').value;
var discount = $('discount').value;
f = (price - (price*discount)/100)*100;
$('sum').value = Math.round(f)/100;
}
</script> 

<input type="text" id="price" value="32.55" />
<input type="text" id="discount" value="" /><span onclick="cntprice()">aprekinat</span>
<input type="text" id="sum" value="" />

Link to comment
Share on other sites

A ir iespējams to automātiski ielādēt?

 

Kas te domats? Ja javasciprt kods, tad vinu var ielikt kada faila un <head> ieladet <script type="text/javascript" src="http://*.js" charset="utf-8"></script>

Link to comment
Share on other sites

pie body taga <body onload="discount.focus()">

Link to comment
Share on other sites

var meginat parkert to mirkli, kad lietotajs uzspiez enter, bet tas ir 4Z risinajums

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   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...