Jump to content

Search the Community

Showing results for tags 'Обьединение двух функций'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Development
    • HTML Coding
    • JavaScript
    • PHP
    • CMS
    • Database
    • Web Server
    • Web-site Development
    • Internet Marketing, SEO
  • Library
    • Tricks and solutions
    • Books
  • Commercial services
    • Freelance
    • Job
    • Goods and Services
  • Our Forum
    • Flame
    • Contests
    • Feedback and Ideas

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Web site


Telegram


Signal


Viber


Skype


From


Interests

Found 1 result

  1. Доброго времени суток. Столкнулся с проблемой, что при подсчете количества введенных слов функция отказывается выполнять умножение с ценой из другой функции... Первая функция: 01 function calc() { 02 03 var type_host = document.getElementById("type_host"); 04 var seo = document.getElementById("seo"); 05 var comment = document.getElementById("comment"); 06 var gallery = document.getElementById("gallery"); 07 var eshop = document.getElementById("eshop"); 08 09 var result = document.getElementById("type_host"); 10 var result = document.getElementById("seo"); 11 var result = document.getElementById("comment"); 12 var result = document.getElementById("gallery"); 13 var result = document.getElementById("eshop"); 14 var result = document.getElementById("result"); 15 16 var price_host = 0; 17 var price_seo = 0; 18 var price_comment = 0; 19 var price_gallery = 0; 20 var price_eshop = 0; 21 var price = 0; 22 price_host += (type_host.checked == true) ? parseInt(type_host.value) : 0; 23 price_seo += (seo.checked == true) ? parseInt(seo.value) : 0; 24 price_comment += (comment.checked == true) ? parseInt(comment.value) : 0; 25 price_gallery += (gallery.checked == true) ? parseInt(gallery.value) : 0; 26 price_eshop += (eshop.checked == true) ? parseInt(eshop.value) : 0; 27 price=price_host+price_seo + price_comment + price_gallery + price_eshop; 28 29 result_host.innerHTML = price_host; 30 result_seo.innerHTML = price_seo; 31 result_comment.innerHTML = price_comment; 32 result_gallery.innerHTML = price_gallery; 33 result_eshop.innerHTML = price_eshop; 34 result.innerHTML = price; 35 } Вторая функция: 1 var textarea = document.getElementsByName("comments")[0]; 2 var counter = document.getElementById("counter"); 3 textarea.onkeyup = function(s) { 4 counter.innerHTML = this.value.split(/ +(?:\S)/).length; 5 } Сам код: 01 <td width="20px"><input type="checkbox" onchange="calc()" value="350" id="type_host" /></td> 02 <td width="60px"></td> 03 <td width="100px"><span id="result_host">0</span> руб.</td> 04 05 <td width="20px"><input type="checkbox" onchange="calc()" value="300" id="seo" /></td> 06 <td width="60px"></td> 07 <td width="100px"><span id="result_seo">0</span> руб.</td> 08 </tr> 09 10 <tr> 11 <td width="20px"><input type="checkbox" onchange="calc()" value="300" id="comment" /></td> 12 <td width="60px"></td> 13 <td width="100px"><span id="result_comment">0</span> руб.</td> 14 15 <td width="20px"><input type="checkbox" onchange="calc()" value="300" id="gallery" /></td> 16 <td width="60px"></td> 17 <td width="100px"><span id="result_gallery">0</span> руб.</td> 18 </tr> 19 20 <tr> 21 <td width="20px"><input type="checkbox" onchange="calc()" value="200" id="eshop" /></td> 22 <td width="60px"></td> 23 <td width="100px"><span id="result_eshop">0</span> руб.</td> 24 <td width="20px"></td> 25 <td width="60px"></td> 26 <td width="100px"></td> 27 </tr> 28 <tr> 29 <td colspan="6" align="center"><h3>Введите текст:</h3></td> 30 </tr> 31 32 <tr> 33 <td colspan="5"><textarea name="comments" onchange="calc()" value="0" cols="38" rows="7"></textarea></td> 34 <td>Введено слов: <span id="counter">0</span></td></tr> 35 <tr><td colspan="6"><center><input type="submit" value="Отправить"> <input type="reset" value="Очистить"></center></td> 36 </tr> 37 38 39 <tr> 40 <td width="80" colspan="2" class="td_result">ИТОГО:</td> 41 <td width="120" colspan="2"></td> 42 <td width="160" class="td_result" colspan="2"><span id="result">0</span> руб.</td> 43 </tr> Что необходимо прописать, чтобы перемножить результат result с counter???
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy