Передать value
Подскажите как сделать чтобы данные с value брались?
<input type="radio" name="gender" value="1" onclick="calculate()">q <input type="radio" name="gender" value="2" onclick="calculate()">q <input type="radio" name="gender" value="3" onclick="calculate()">q <input type=checkbox value="4" onclick="calculate()" >q <input type=checkbox value="5" onclick="calculate()" >q <input type="text" id="total"> <script> function calculate() { var inp = document.getElementsByTagName('input'); var length = inp.length; var mas = []; for (var i = 0; i < length; i++) { if (inp[i].checked) { mas.push(inp[i].nextSibling.nodeValue); } } var div = document.getElementById('total'); div.value = mas.join(',') ; } </script> |
inp[i].value0_o? |
Цитата:
<!DOCTYPE html> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=windows-1251' /> <!-- <script src='http://code.jquery.com/jquery-latest.js'></script> <script src="https://code.angularjs.org/1.3.9/angular.min.js"></script> <script src="https://code.angularjs.org/1.3.9/angular-route.js"></script> --> <style type='text/css'> </style> <script type='text/javascript'> </script> </head> <body> <input type="radio" name="gender" value="1" onclick="calculate()" />q <input type="radio" name="gender" value="2" onclick="calculate()" />q <input type="radio" name="gender" value="3" onclick="calculate()" />q <input type=checkbox value="4" onclick="calculate()" />q <input type=checkbox value="5" onclick="calculate()" />q <input type="text" id="total" /> <script> function calculate() { var inp = document.getElementsByTagName('input'); var length = inp.length; var mas = []; for (var i = 0; i < length; i++) { if (inp[i].checked) { mas[mas.length]=inp[i].value; }; }; var div = document.getElementById('total'); div.value = mas.join(','); }; </script> </body> </html> |
Часовой пояс GMT +3, время: 12:35. |