Показать сообщение отдельно
  #1 (permalink)  
Старый 18.07.2011, 01:10
Новичок на форуме
Отправить личное сообщение для Found Посмотреть профиль Найти все сообщения от Found
 
Регистрация: 18.07.2011
Сообщений: 2

Поочерёдная очистка поля input
Длинну можно вводить ручками или юзать выпадающий список, нужно чтоб при переключении с одного на другой тип ввода очищалось полей с выведенной ценой автоматически. вот код:
Функция подсчёта цены
Код:

function vCalculateCost(leng, discount, isKatushka) {
      var pr = parseInt(document.getElementById('baseprice').value);

      if (isKatushka) {
         var katushka = parseInt(document.getElementById('katushka').value);
         if (!katushka) katushka = 0;
         basecine = katushka * 762 * pr;
         leng = katushka * 762;
         document.getElementById('viewprice').value = basecine;
         document.getElementById('length_of_product').value = leng;
         if (discount > 0) {
            var cine = parseInt(document.getElementById('undiscounted_price').value) * leng;
            cine = cine - basecine;
            document.getElementById('allDiscountValue').value = cine;
         }
      } else {
         leng = parseFloat(leng);
         if (!leng) leng = 0;
         var basecine = Math.round(pr * leng);
         document.getElementById('viewprice').value = basecine;
         document.getElementById('katushka').value = 0;
         if (discount > 0) {
            var cine = parseInt(document.getElementById('undiscounted_price').value) * leng;
            cine = Math.round(cine - basecine);
            document.getElementById('allDiscountValue').value = cine;
         }
      }
   }



Собственно вид странички(без выпадающего списка длинн)
Код:
<td>
   <a href="#" onclick="TagToTip('howToPage', WIDTH, 450, CLOSEBTN, true, FOLLOWMOUSE, false, FONTSIZE, '12px', BGCOLOR, '#ffffff', BORDERCOLOR, '#ffffff', SHADOWCOLOR, '#ffffff', SHADOWWIDTH, 0); return false;">Lkbyf: <img src="img/question_sign.jpg" width="15" height="15" border="0" /></a> <div style="font-size: 0px; height: 7px;"></div>
   <input type="text" name="length_of_product" id="length_of_product" onkeyup="vCalculateCost(this.value, {$dicsount_present}, false);" class="f45" /> ñì
   <div style="display: none;" id="howToPage">
   <b>{$howToPage.title|stripslashes}</b>
   <br/><br/>
   {$howToPage.text|stripslashes}
   </div>
</td>
<td align="right">
   Цена <div style="font-size: 0px; height: 7px;"></div>
   <input type="text" name="viewprice" id="viewprice" readonly="" class="f74" /> {$smarty.const.MONEY_SIGN}
</td>


ну и списочек
Код:
<select name="id[1]" id="attrib-1">
<option value="1">1 </option>
<option value="2">2 </option>
<option value="3">3 </option>
<option value="4">4 </option>
<option value="5">5 </option>
</select>
Ответить с цитированием