saintdevi Posted February 18, 2009 Report Share Posted February 18, 2009 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 :) Quote Link to comment Share on other sites More sharing options...
cucumber Posted February 18, 2009 Report Share Posted February 18, 2009 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="" /> Quote Link to comment Share on other sites More sharing options...
saintdevi Posted February 18, 2009 Author Report Share Posted February 18, 2009 (edited) Jēēēē, viss pa skaisto, lielais paldies :)) Tik kā lai uztaisa podziņu aprēķināt, lai lapa nepārlēdējas? Ar type="submit" lapa pārlādējas un laukumi paliek tukši ... :( Edited February 18, 2009 by saintdevi Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 18, 2009 Report Share Posted February 18, 2009 ar type="button" :) Quote Link to comment Share on other sites More sharing options...
saintdevi Posted February 18, 2009 Author Report Share Posted February 18, 2009 Jā der :)) A ir iespējams to automātiski ielādēt? :) :)) :)) Patišām liels prieks, ka te tādi atsaucīgi cilvēki :)) Quote Link to comment Share on other sites More sharing options...
cucumber Posted February 18, 2009 Report Share Posted February 18, 2009 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> Quote Link to comment Share on other sites More sharing options...
saintdevi Posted February 18, 2009 Author Report Share Posted February 18, 2009 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> Automātiski inputā ielādēt rezultātu, lai nav uz pogas "APRĒĶINĀT JĀSPIEŽ" ... Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 18, 2009 Report Share Posted February 18, 2009 Var šitā, ja pareizi sapratu, kas vajadzīgs: <input type="text" id="discount" value="" onchange="cntprice()"/> Quote Link to comment Share on other sites More sharing options...
saintdevi Posted February 18, 2009 Author Report Share Posted February 18, 2009 Var šitā, ja pareizi sapratu, kas vajadzīgs: <input type="text" id="discount" value="" onchange="cntprice()"/> Jā tas i tas :)) Paldies liels visiem :)) A kā izmukt no problēmas, ja nospiež "enter" un lapa pārlādējas? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 18, 2009 Report Share Posted February 18, 2009 Nelikt <input ...> laukus iekš <form>...</form> Quote Link to comment Share on other sites More sharing options...
cucumber Posted February 18, 2009 Report Share Posted February 18, 2009 pie body taga <body onload="discount.focus()"> Quote Link to comment Share on other sites More sharing options...
saintdevi Posted February 18, 2009 Author Report Share Posted February 18, 2009 Nelikt <input ...> laukus iekš <form>...</form> Ņu a ja savādāk nekādi nevar, ko tad? :o :( Quote Link to comment Share on other sites More sharing options...
saintdevi Posted February 18, 2009 Author Report Share Posted February 18, 2009 pie body taga <body onload="discount.focus()"> Ņeke, nestrādā :( Quote Link to comment Share on other sites More sharing options...
cucumber Posted February 18, 2009 Report Share Posted February 18, 2009 var meginat parkert to mirkli, kad lietotajs uzspiez enter, bet tas ir 4Z risinajums Quote Link to comment Share on other sites More sharing options...
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.