Zoom Posted September 11, 2006 Report Share Posted September 11, 2006 Man ir 10 checkboxi. Iekeķsējot atsevišķu boxsus man saskaitās to vērtības. Es domāju to ielikt ciklā. Kur atķeksēti tiek saskaitīti. Un attiecīgi, ja atķeksē atpakaļ, tad tā vērtība atņemas. Pareizi domāju? Link to comment Share on other sites More sharing options...
Delfins Posted September 11, 2006 Report Share Posted September 11, 2006 (edited) kam tev to vajag ? Es tādiem gadījumiem taisu bin2dec() strBin = ""; for (i=0;i<checkBoxCunt;i++) { strBin .= (int) !empty($_POST['checkbox'][i]); } decVal = bindec(strBin); Selektā arī var atselektēt visu ko vajag: select ... where OPTS & 0x8 Edited September 11, 2006 by Delfins Link to comment Share on other sites More sharing options...
bubu Posted September 11, 2006 Report Share Posted September 11, 2006 Delfin: izlasi foruma sadaļas nosaukumu. Zoom: ko tu pareizi domā? Man nav skaidrs, ko tu gribi panākt ar savu čekbokšu ķeksēšanu. Link to comment Share on other sites More sharing options...
Delfins Posted September 11, 2006 Report Share Posted September 11, 2006 bubu, nu tieši tā es realizēju "opcijas", protams, jāskatās konkrētu gadījumu, vai opcijas ID jāpadod čerez value vai pietiek vienkārši ar numur_pēc_kārtas. Un tāpēc jautāju, ko viņš grib darīt ar tiem čekbokšiem Link to comment Share on other sites More sharing options...
Zoom Posted September 11, 2006 Author Report Share Posted September 11, 2006 (edited) http://www.codingforums.com/showthread.php?t=81268 piemērs <form action="" method="POST"> <table width="200" border="1"> <tr> <td width="75">Vertiba1</td> <td width="109"> <input type="checkbox" name="checkbox" value="1"> </td> </tr> <tr> <td>Vertiba2</td> <td><input type="checkbox" name="checkbox2" value="2"></td> </tr> <tr> <td>Vertiba3</td> <td><input type="checkbox" name="checkbox3" value="3"></td> </tr> <tr> <td>Vertiba4</td> <td><input type="checkbox" name="checkbox4" value="4"></td> </tr> <tr> <td>Vertiba5</td> <td><input type="checkbox" name="checkbox5" value="5"></td> </tr> <tr> <td>Vertiba6</td> <td><input type="checkbox" name="checkbox6" value="6"></td> </tr> <tr> <td>Vertiba7</td> <td><input type="checkbox" name="checkbox7" value="7"></td> </tr> <tr> <td>Vertiba8</td> <td><input type="checkbox" name="checkbox8" value="8"></td> </tr> <tr> <td>Vertiba9</td> <td><input type="checkbox" name="checkbox9" value="8"></td> </tr> <tr> <td>Vertiba10</td> <td><input type="checkbox" name="checkbox10" value="10"></td> </tr> <tr> <td>Vertiba11</td> <td><input type="checkbox" name="checkbox11" value="11"></td> </tr> <tr> <td>Vertiba12</td> <td><input type="checkbox" name="checkbox12" value="12"></td> </tr> </table> </form> Ieķeksēto boxu vērtības jāsaskaita. Un tāpēc jautāju, ko viņš grib darīt ar tiem čekbokšiem naudu skaitīt... Edited September 11, 2006 by Zoom Link to comment Share on other sites More sharing options...
v3rb0 Posted September 11, 2006 Report Share Posted September 11, 2006 var sum=0; .. <input type="checkbox" name="checkbox12" value="12" onclick="sum += ((this.checked)?1:-1)*this.value;" /> Link to comment Share on other sites More sharing options...
Zoom Posted September 11, 2006 Author Report Share Posted September 11, 2006 (edited) http://paste.php.lv/4411 te mainās, kad uzklišķina peli. Kā var uztaisīt, ka ierakstot sakitu uzreiz man parādas summa? onBlur meiģināju, bet nesanāca. ar onmouseover var dabūt tīkamu rezultātu Edited September 11, 2006 by Zoom Link to comment Share on other sites More sharing options...
Stopp Posted September 12, 2006 Report Share Posted September 12, 2006 (edited) onchange edīte: pagpag, neiedziļinājos tanī tavā kodā, kad rakstīju.. viņš tāds neskaidrs. atbrīvosi, lūdzu, no visa liekā ? Edited September 12, 2006 by Stopp Link to comment Share on other sites More sharing options...
Grey_Wolf Posted September 12, 2006 Report Share Posted September 12, 2006 Stopp --> bezceriigi jo Zoom nezina kas tur ir lieks un kas nav....... Zoom --> cekboksiem izmanto Onclick teksta laukiem Onchange ------------------- /* This script is Copyright © Paul McFedries and #16 Logophilia Limited (http://www.mcfedries.com/). #17 Permission is granted to use this script as long as #18 this Copyright notice remains in place.*/ Link to comment Share on other sites More sharing options...
Stopp Posted September 12, 2006 Report Share Posted September 12, 2006 <script> function skaitit() { var skaits=0; var checki=document.getElementsByName("c"); for(i=0;i<checki.length;i++) { if (checki[i].checked==true) skaits+=1; } alert(skaits); } </script> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> <input type="checkbox" name="c" onClick="skaitit()"/> Link to comment Share on other sites More sharing options...
Zoom Posted September 12, 2006 Author Report Share Posted September 12, 2006 <script language="javascript" type="text/javascript"> function Calculate (obj) { ips=obj.parentNode.getElementsByTagName('INPUT'); sum=0; for (i=0;i<ips.length;i++){ if (ips[i].checked){ sum+=ips[i].value*1; } } document.getElementById('total').value=sum; } </script> <input name="prece" type="checkbox" id="prece" onClick="Calculate(this)" value="1"> <input name="prece" type="checkbox" id="prece" onClick="Calculate(this)" value="2"> <input id="total" size="5"> Link to comment Share on other sites More sharing options...
Recommended Posts