Показать сообщение отдельно
  #5 (permalink)  
Старый 05.04.2017, 18:31
Интересующийся
Отправить личное сообщение для zoomx25 Посмотреть профиль Найти все сообщения от zoomx25
 
Регистрация: 03.04.2017
Сообщений: 10

При пустом значение Комплект RTK Ровер RTK Тахеометр
выводиться NaN

Вот полный код

<script type="text/javascript">
function  cal(){
 var result = document.getElementById('result')
 var days=document.getElementById('days').value	
 var days2=document.getElementById('days2').value 
 var days3 = document.getElementById('days3').value
 var days4 = document.getElementById('days4').value
 var days5 = document.getElementById('days5').value
 var value = document.getElementById('rtk_complectId').value
 var value2 = document.getElementById('rtk_roverId').value
 var value3 = document.getElementById('taheomId').value
 var rtk_complect_r;
 var rtk_rover_r;
 var taheom_r;
 
  days=parseFloat(days)
  days2=parseFloat(days2)
  days3=parseFloat(days3)
  days4=parseFloat(days4)
  days5=parseFloat(days5)
  
  var r_ls=0
  var r_p_gps=0
  var rtk_complect_r=0
  var rtk_rover_r=0
  var taheom_r=0
  var price=0
   
  if (days==0) {r_ls=0;}
  else if (days<=3) { r_ls=75000;}
  else if (days<=7) { r_ls=days*25000;}
  else if (days<=14) { r_ls=days*21000;}
  else if (days<=30) { r_ls=days*18000;}
  else if (days>=31) { r_ls=days*15000;}
  
  if (days2==0) {r_p_gps=0;}
  else if (days2<=3) { r_p_gps=5400;}
  else if (days2<=7) { r_p_gps=days2*1800;}
  else if (days2<=14) { r_p_gps=days2*1500;}
  else if (days2<=30) { r_p_gps=days2*1200;}
  else if (days2>=31) { r_p_gps=days2*1000;}
  
  if (value == "rtk_uhf") {
  if (days3==0) {rtk_complect_r=0;}
  else if (days3<=3) { rtk_complect_r=18000;}
  else if (days3<=7) { rtk_complect_r=days3*6000;}
  else if (days3<=14) { rtk_complect_r=days3*5000;}
  else if (days3<=30) { rtk_complect_r=days3*4500;}
  else  { rtk_complect_r=days3*4000;}
}
  else if (value == "rtk_gsm") {
  if (days3==0) {value=0;}
  else if (days3<=3) { rtk_complect_r=16500;}
  else if (days3<=7) { rtk_complect_r=days3*5500;}
  else if (days3<=14) { rtk_complect_r=days3*4500;}
  else if (days3<=30) { rtk_complect_r=days3*4000;}
  else  { rtk_complect_r=days3*3500;}
}
   if (value2 == "rtk_gps") {
  if (days4==0) {rtk_rover_r=0;}
  else if (days4<=3) { rtk_rover_r=6900;}
  else if (days4<=7) { rtk_rover_r=days4*2300;}
  else if (days4<=14) { rtk_rover_r=days4*2000;}
  else if (days4<=30) { rtk_rover_r=days4*1700;}
  else  { rtk_rover_r=days4*1500;}
}
  else if (value2 == "rtk_gps_glonass") {
  if (days4==0) {rtk_rover_r=0;}
  else if (days4<=3) { rtk_rover_r=10500;}
  else if (days4<=7) { rtk_rover_r=days4*3500;}
  else if (days4<=14) { rtk_rover_r=days4*3000;}
  else if (days4<=30) { rtk_rover_r=days4*2500;}
  else  { rtk_rover_r=days4*2200;}
}
   if (value3 == "tah_na_otrzh") {
  if (days5==0) {taheom_r=0;}
  else if (days5<=3) { taheom_r=4500;}
  else if (days5<=7) { taheom_r=days5*1500;}
  else if (days5<=14) { taheom_r=days5*1100;}
  else if (days5<=30) { taheom_r=days5*900;}
  else  { taheom_r=days5*800;}
}
  else if (value3 == "tah_bez_6_5") {
  if (days5==0) {taheom_r=0;}
  else if (days5<=3) { taheom_r=6600;}
  else if (days5<=7) { taheom_r=days5*2200;}
  else if (days5<=14) { taheom_r=days5*1800;}
  else if (days5<=30) { taheom_r=days5*1600;}
  else  { taheom_r=days5*1400;}
}
   if (value3 == "tah_bez_2_1") {
  if (days5==0) {taheom_r=0;}
  else if (days5<=3) { taheom_r=8100;}
  else if (days5<=7) { taheom_r=days5*2700;}
  else if (days5<=14) { taheom_r=days5*2300;}
  else if (days5<=30) { taheom_r=days5*2100;}
  else  { taheom_r=days5*1900;}
}
  else if (value3 == "tah_robot") {
  if (days5==0) {taheom_r=0;}
  else if (days5<=3) { taheom_r=13500;}
  else if (days5<=7) { taheom_r=days5*4500;}
  else if (days5<=14) { taheom_r=days5*4000;}
  else if (days5<=30) { taheom_r=days5*3500;}
  else  { taheom_r=days5*3000;}
}



  price=r_ls+r_p_gps+rtk_complect_r+rtk_rover_r+taheom_r;
  if (result.value) {
  price = parseInt(price.value);
  }

  
 document.getElementById("result_ls").innerHTML=r_ls;
 document.getElementById("result_p_gps").innerHTML=r_p_gps;
 document.getElementById('summ_rtk_complect').innerHTML = rtk_complect_r;
 document.getElementById('summ_rtk_rover_r').innerHTML = rtk_rover_r;
 document.getElementById('summ_taheom_r').innerHTML = taheom_r;
 result.innerHTML = price;
}

function isright(obj)
	{
	if (obj.value>999) obj.value=999; 
	if (obj.value<1) obj.value=0;
}

</script>
</head>

<body>
<h1>Калькулятор</h1>
<form id="form1" name="form1" method="post" action="">
  <table width="896" border="1" align="center" cellpadding="5" cellspacing="0">
    <tr>
      <td width="341"><p>Лазерный сканер</p>
      <p>&nbsp;</p></td>
        <td width="199"><input type="number"  min="0" max="999999" value="0" name="days" id="days" onkeyup="this.value=this.value.replace(/[^0-9]+/g,'');"/></td>
      <td width="158">результат</td>
      <td width="148"><span id="result_ls">0</span> руб.</td>
    </tr>
    <tr>
      <td><p>Приемник GPS (Статика L2)</p>
      <p>&nbsp;</p></td>
        <td><input type="number"  min="0" max="999999" value="0" name="days2" id="days2" onkeyup="this.value=this.value.replace(/[^0-9]+/g,''); isright(this);"/></td>
      <td>результат</td>
      <td><span id="result_p_gps">0</span> руб.</td>
    </tr>
    <tr>
    <tr>
      <td><p>Комплект RTK
          </p>
        <p>
          <select size="1" id="rtk_complectId" onChange="cal()">
            <option value="rtk_uhf">UHF 35W</option>
            <option value="rtk_gsm">GSM/GPRS</option>
          </select>
        </p>
	  </td>
    <td><input type="number"  min="0" max="999999" value="0" name="days3" id="days3" onkeyup="this.value=this.value.replace(/[^0-9]+/g,''); isright(this);"/></td>
      <td>результат</td>
      <td><span id="summ_rtk_complect">0</span> руб.</td>
    </tr>
    <tr>
    <tr>
      <td><p>Ровер RTK
          </p>
        <p>
          <select size="1" id="rtk_roverId" onChange="cal()">
            <option value="rtk_gps">GPS</option>
            <option value="rtk_gps_glonass">GPS/Glonass</option>
          </select>
        </p>
	  </td>
    <td><input type="number"  min="0" max="999999" value="0" name="days4" id="days4" onkeyup="this.value=this.value.replace(/[^0-9]+/g,''); isright(this);" /></td>
      <td>результат</td>
      <td><span id="summ_rtk_rover_r">0</span> руб.</td>
    </tr>
    <tr>
      <td><p>Тахеометр
          </p>
        <p>
          <select size="1" id="taheomId" onChange="cal()">
            <option value="tah_na_otrzh">На отрожатель</option>
            <option value="tah_bez_6_5">Безотрожательный (6";5")</option>
            <option value="tah_bez_2_1">Безотрожательный (2";1")</option>
            <option value="tah_robot">Роботизированный</option>
          </select>
        </p>
	  </td>
    <td><input type="number"  min="0" max="999999" value="0" name="days5" id="days5" onkeyup="this.value=this.value.replace(/[^0-9]+/g,''); isright(this);"/></td>
      <td>результат</td>
      <td><span id="summ_taheom_r">0</span> руб.</td>
    </tr>
    <tr>
        <td colspan="2"><p>&nbsp;
          </p>
          <p>
            <input type="button" name="button" id="button" onClick="cal()" value="вычислить" />
          </p>
        <p>&nbsp;</p></td>
     <td>Итого</td>
      <td><span id="result">0</span> руб.</td>   
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>
Ответить с цитированием