- 1

How to insert variable in to html

I have this code: ------------------------------- <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <script> var p=500; u=0; s=0; g=0; function power(sel) { // alert (sel.options[sel.selectedIndex].text); p=sel.options[sel.selectedIndex].text; if (checkBox.checked) { g=50; } else {g=0;} s=(p/2.5)+u*42+20+g; } function visota(sel) { // alert (sel.options[sel.selectedIndex].text); if (checkBox.checked) { g=50; } else {g=0;} u=sel.options[sel.selectedIndex].text; s=(p/2.5)+u*42+20+g; } </script> <div class="tarrifs"> <table width="830" align="center" cellpadding="3" cellspacing="3" > <td align="right" class="tt_ths">Электропитание</td> <td align="right" colspan="2"> <label><select id="pitanie" onChange="power(this); write(this)"> <option value="1">500</option><option value="2">750</option> <option value="3">1000</option><option value="4">1250</option> <option value="5">1500</option><option value="6">2000</option> </select></label> <small>Вт</small></td> </tr> <tr> <td align="right" class="tt_ths">Технологический размер</td> <td align="right" colspan="2"> <label><select id="visota" onChange="visota(this);"><option value="1">0</option><option value="2">1</option><option value="3">2</option><option value="4">3</option><option value="5">4</option><option value="6">5</option></select></label> <small>U</small></td> </tr> <tr> <td width="30%" align="right" class="tt_ths">Скорость доступа к внутренней сети<sup>1</sup></td> <td align="right" colspan="2"><span id="podklyucheniye1">до 100</span> <small>Мбит/c</small></td> </tr> <tr> <td align="right" class="tt_t

27th Sep 2017, 12:22 PM
Parviz M. Kandiyorov
Parviz M. Kandiyorov - avatar
3 Answers
0
Did you write the code or copied from somewhere else?
27th Sep 2017, 12:47 PM
Calviղ
Calviղ - avatar
0
I`am write
28th Sep 2017, 4:25 AM
Parviz M. Kandiyorov
Parviz M. Kandiyorov - avatar
0
I did some change in script: <script> var p=500; u=0; s=0; g=0; sum=0; function power(sel) { // alert (sel.options[sel.selectedIndex].text); p=sel.options[sel.selectedIndex].text; if (checkBox.checked) { g=50; } else {g=0;} s=(p/2.5)+u*42+20+g; sum=s; document.getElementById("result").value = sum; } function visota(sel) { // alert (sel.options[sel.selectedIndex].text); if (checkBox.checked) { g=50; } else {g=0;} u=sel.options[sel.selectedIndex].text; s=(p/2.5)+u*42+20+g; sum=s; document.getElementById("result").value = sum; } </script>
28th Sep 2017, 4:27 AM
Parviz M. Kandiyorov
Parviz M. Kandiyorov - avatar