![]() | |
| | #1 (permalink) |
| Üye Üyelik Tarihi: 04/2007
Mesaj: 1
|
Arkadaşlar söyle bir sorunum var aşağıda javascriipt kodunu koydun js den pek anlamam yardım ederseniz çok sevinirim. Sorun şu kullanıcı aşağıdaki seçenekleri işaretleyecek ve ben her checkbox a value olarak farklı bir değer vermem gerekiyor. Ve kullanıcı sadece 40 value değeri aşmaması gerekli yani 40 işaretlemeler 40 ı geçerse uyarılması gerekli , checkbox'a farklı değerler vererek bir örnek js de işimi görürü. şimdiden çok teşekürler.... <script type="text/javascript" > function calculateTotal(inputItem) { with (inputItem.form) { // Process each of the different input types in the form. if (inputItem.type == "radio") { // Process radio buttons. // Subtract the previously selected radio button value from the total. calculatedTotal.value = eval(calculatedTotal.value) - eval(previouslySelectedRadioButton.value); // Save the current radio selection value. previouslySelectedRadioButton.value = eval(inputItem.value); // Add the current radio button selection value to the total. calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value); } else { // Process check boxes. if (inputItem.checked == false) { // Item was uncheck. Subtract item value from total. calculatedTotal.value = eval(calculatedTotal.value) - eval(inputItem.value); } else { // Item was checked. Add the item value to the total. calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value); } } // Total value should never be less than 0. if (calculatedTotal.value < 0) { InitForm(); } // Return total value. return(formatCurrency(calculatedTotal.value)); } } // Format a value as currency. function formatCurrency(num) { num = num.toString().replace(/\$|\,/g,''); if(isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num*100+0.50000000001); cents = num%100; num = Math.floor(num/100).toString(); if(cents<10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3)); return (((sign)?'':'-') + '' + num + '.' + cents); } // This function initialzes all the form elements to default values. function InitForm() { // Reset values on form. document.selectionForm.total.value='0'; document.selectionForm.calculatedTotal.value=0; document.selectionForm.previouslySelectedRadioButt on.value=0; // Set all checkboxes and radio buttons on form to unchecked. for (i=0; i < document.selectionForm.elements.length; i++) { if (document.selectionForm.elements[i].type == 'checkbox' | document.selectionForm.elements[i].type == 'radio') { document.selectionForm.elements[i].checked = false; } } } </script> <body onload="InitForm();" onreset="InitForm();"> <div align="center"> <table><tr><td> <form method="POST" name="selectionForm"> Seçenek A<input type="checkbox" name="Steak" value="10.00" onclick="this.form.total.value=calculateTotal(this );"> Seçenek B <input type="checkbox" name="Chicken" value="15.00" onclick="this.form.total.value=calculateTotal(this );"> Seçenek C <input type="checkbox" name="Sushi" value="10.00" onclick="this.form.total.value=calculateTotal(this );"> Seçenek D <input type="checkbox" name="Sushi" value="10.00" onclick="this.form.total.value=calculateTotal(this );"> Seçenek E <input type="checkbox" name="Sushi" value="15.00" onclick="this.form.total.value=calculateTotal(this );"> Seçenek F <input type="checkbox" name="Sushi" value="15.00" onclick="this.form.total.value=calculateTotal(this );"> <br><br> <br> <br> <input type="hidden" name="calculatedTotal" value="0"> <input type="hidden" name="previouslySelectedRadioButton" value="0"> <strong>toplam</strong> <input type="text" name="total" readonly onfocus="this.blur();"> </form> </td></tr></table> </div> <p><p> |
| | |
| | #2 (permalink) |
| Üye Üyelik Tarihi: 05/2007
Mesaj: 26
| PHP Kodu: |
| | |
![]() |
| Bookmarks |
| Seçenekler | |
| |
Benzer Konular | ||||
| Konu | Konuyu açana göre | Forum | Cevap | En Son Mesaj |
| checkbox | ilkbahar | PHP | 2 | 14/04/2007 00:17 |
| asp checkbox | darkface | ASP | 1 | 05/04/2007 10:27 |
| checkbox biri işaretlenince altdaki değer checkbox otomatik checked olsun | militaN | Javascript / DHTML / Ajax | 1 | 02/04/2007 14:37 |
| checkbox ile seçilmiş bilgileri database'ye kayıt etme | ercems | ASP | 3 | 05/06/2005 21:15 |
| checkbox | KanKi | PHP | 5 | 26/10/2004 11:35 |
| Reklamlar & Desteklenenler | |
| Hassas Valf | Hassas Kaplama | Antalyamız | Gazete | Ticari Bilişim | Hakan Müştak | Rüya Tabirleri | Kadın | Hastalıklar | Cepte msn ve e-posta | Webmaster | Antalya Aupair | Turkish Property Antalya | Forum | Chat | Perde | Adsl | Araba | bolindir.com | guncelle.com | livescore | Web Tasarım | evden eve nakliyat | forum | evden eve | sohbet | Resimcim| Kalifiye İnsan Kaynakları | Web Tasarım | Oyun | Yusuf KOÇ | Akın Yorulmaz | şiir | UFO | Web Tasarım | Oyunlar | Canlı Tv | |