калькулятор js jqweri
Доброе время суток есть таблица я должен убрать с таблици инпут и записать везде о
когда я делаю мой калькулятор перестает работать и я не понимаю где ошибка
<script>
function formreset() {
document.getElementById("campivot").reset();
}
function calcamrlia() {
var campivot = document.campivot;
if (!campivot.price2.value) {
alert("Please type the value in High Price field !");
return false;
} else if (!campivot.price3.value) {
alert("Please type the value in Low Price field !");
return false;
} else if (!campivot.price4.value) {
alert("Please type the value in Close price field !");
return false;
}
campivot.sup1.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 12) * 1000) / 1000;
campivot.sup2.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 6) * 1000) / 1000;
campivot.sup3.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 4) * 1000) / 1000;
campivot.sup4.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 2) * 1000) / 1000;
campivot.res1.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 12) * 1000) / 1000;
campivot.res2.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 6) * 1000) / 1000;
campivot.res3.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 4) * 1000) / 1000;
campivot.res4.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 2) * 1000) / 1000;
}
</script>
<div id="ezmain">
<fieldset class="bordformt" style="border: 2px solid #0066B3;">
<legend class="bordformt" align="center" style="border: 0px solid #0066B3; padding:
5px 20px; margin- left: 20px;">
<center>Camarilla Pivot Trading Calculator</center>
</legend>
</br>
<div id="ezchild">
<fieldset class="bordformt" style="border: 1px solid #0066B3;">
<legend class="bordformt" align="left" style="border: 1px solid #0066B3; padding: 4px 11px; margin- left: 20px;">Camarilla Trade Range</legend>
<form id="campivot" name="campivot" style="background-color: white;">
<table width='100%'>
<tr>
<td width='40%'>Camarilla Level- H4 ↑</td>
<td width='60%' ><input id="res4" class="widgetext"></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- H3 ↓</td>
<td width=‘60%’>: <input class="widgetext" id="res3" name="res3" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- H2 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="res2" name="res2" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- H1 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="res1" name="res1" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L1 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="sup1" name="sup1" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L2 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="sup2" name="sup2" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L3 ↑</td>
<td width=‘60%’>: <input class="widgetext" id="sup3" name="sup3" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L4 ↓</td>
<td width=‘60%’>: <input class="widgetext" id="sup4" name="sup4" size="30" type="text" /></td>
</tr>
<tr></tr>
<tr></tr>
</table>
</fieldset>
<br />
<fieldset class="bordformt" style="border: 1px solid #0066B3;">
<legend class="bordformt" align="left" style="border: 1px solid #0066B3; padding: 4px 11px; margin- left: 20px;">Enter The Current Price</legend>
<table width='100%'>
<tr>
<th width="30%">High Price :</th>
<th width="30%">Low Price :</th>
<th width="30%">Close Price :</th>
</tr>
<tr>
<td width="30%"><input class="widgetext" id="price2" name="price2" placeholder="5650" type="text" title="High Price" /></td>
<td width="30%"><input class="widgetext" id="price3" name="price3" placeholder="5560" type="text" title="Low Price" /></td>
<td width="30%"><input class="widgetext" id="price4" name="price4" placeholder="5610" type="text" title="Close Price" /></td>
</tr>
<tr></tr>
<tr></tr>
</table>
</form>
</fieldset>
<br />
<fieldset class="bordformt" style="border: 1px solid #0066B3;">
<legend class="bordformt" align="left" style="border: 1px solid #0066B3; padding: 4px 11px; margin- left: 20px;">Calculate the Level</legend>
</br>
<center>
<input onclick='calcamrlia(campivot);' value='Calculate' style='font-size:16px;width:115px;line-height:25px;font-weight:bold;' type='button' value='Camarilla Pivot Calculator' />
<input onclick='formreset();' value='Reset' style='font-size:16px;width:115px;line-height:25px;font-weight:bold;' type='button' value='Reset Calculator' />
</center>
</fieldset>
<br/>
</div>
</div>
|
misha.korolcov,
<div id="ezmain">
<fieldset class="bordformt" style="border: 2px solid #0066B3;">
<legend class="bordformt" align="center" style="border: 0px solid #0066B3; padding:
5px 20px; margin- left: 20px;">
<center>Camarilla Pivot Trading Calculator</center>
</legend></fieldset>
</br>
<form id="campivot" name="campivot" style="background-color: white;">
<div id="ezchild">
<fieldset class="bordformt" style="border: 1px solid #0066B3;">
<legend class="bordformt" align="left" style="border: 1px solid #0066B3; padding: 4px 11px; margin- left: 20px;">Camarilla Trade Range</legend>
<table width='100%'>
<tr>
<td width='40%'>Camarilla Level- H4 ↑</td>
<td width='60%' ><input id="res4" class="widgetext"></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- H3 ↓</td>
<td width=‘60%’>: <input class="widgetext" id="res3" name="res3" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- H2 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="res2" name="res2" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- H1 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="res1" name="res1" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L1 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="sup1" name="sup1" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L2 ↔</td>
<td width=‘60%’>: <input class="widgetext" id="sup2" name="sup2" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L3 ↑</td>
<td width=‘60%’>: <input class="widgetext" id="sup3" name="sup3" size="30" type="text" /></td>
</tr>
<tr>
<td width=‘40%’>Camarilla Level- L4 ↓</td>
<td width=‘60%’>: <input class="widgetext" id="sup4" name="sup4" size="30" type="text" /></td>
</tr>
<tr></tr>
<tr></tr>
</table>
</fieldset>
<br />
<fieldset class="bordformt" style="border: 1px solid #0066B3;">
<legend class="bordformt" align="left" style="border: 1px solid #0066B3; padding: 4px 11px; margin- left: 20px;">Enter The Current Price</legend>
<table width='100%'>
<tr>
<th width="30%">High Price :</th>
<th width="30%">Low Price :</th>
<th width="30%">Close Price :</th>
</tr>
<tr>
<td width="30%"><input class="widgetext" id="price2" name="price2" placeholder="5650" type="text" title="High Price" /></td>
<td width="30%"><input class="widgetext" id="price3" name="price3" placeholder="5560" type="text" title="Low Price" /></td>
<td width="30%"><input class="widgetext" id="price4" name="price4" placeholder="5610" type="text" title="Close Price" /></td>
</tr>
<tr></tr>
<tr></tr>
</table>
</fieldset>
<br />
<fieldset class="bordformt" style="border: 1px solid #0066B3;">
<legend class="bordformt" align="left" style="border: 1px solid #0066B3; padding: 4px 11px; margin- left: 20px;">Calculate the Level</legend>
</br>
<center>
<input onclick='calcamrlia(campivot);' value='Calculate' style='font-size:16px;width:115px;line-height:25px;font-weight:bold;' type='button' value='Camarilla Pivot Calculator' />
<input onclick='formreset();' value='Reset' style='font-size:16px;width:115px;line-height:25px;font-weight:bold;' type='button' value='Reset Calculator' />
</center>
</fieldset>
<br/>
</div>
</form></div>
<script>
function formreset() {
document.getElementById("campivot").reset();
}
function calcamrlia() {
var campivot = document.campivot;
if (!campivot.price2.value) {
alert("Please type the value in High Price field !");
return false;
} else if (!campivot.price3.value) {
alert("Please type the value in Low Price field !");
return false;
} else if (!campivot.price4.value) {
alert("Please type the value in Close price field !");
return false;
}
campivot.sup1.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 12) * 1000) / 1000;
campivot.sup2.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 6) * 1000) / 1000;
campivot.sup3.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 4) * 1000) / 1000;
campivot.sup4.value = Math.round((1 * campivot.price4.value - (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 2) * 1000) / 1000;
campivot.res1.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 12) * 1000) / 1000;
campivot.res2.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 6) * 1000) / 1000;
campivot.res3.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 4) * 1000) / 1000;
campivot.res4.value = Math.round((1 * campivot.price4.value + (1 * campivot.price2.value - 1 * campivot.price3.value) * 1.1 / 2) * 1000) / 1000;
}
</script>
|
спс но ето мой же код а мне нужно забрать инпути ,я думаю переписать весь код на jq
|
misha.korolcov,
не понимаю ваших сообщений, я поправил расположение тега <form > и </form> в коде выше. |
извините не увидел спс но проблема била как переписать функцию чтоб если убрать инпути функция записавила в тд а то если убрать то она не работает , но как я писал я счас перепишу на jq . Спс , еще раз
|
Цитата:
Цитата:
|
у меня
<form>
<div id="calculator">
<div class="container">
<div class="row">
<div class="col-10 offset-2">
<h6> Pivot Calculator</h6>
</div>
</div>
<div class="row">
<div class="col-5 offset-1">
<div class="row">
<div class="col-2 px-0">
<p> HIGH</p>
</div>
<div class="col-10">
<input type="text" id="price2">
</div>
</div>
</div>
<div class="col-2 offset-1 ">
<button type="button" id="rezult">CALCULATE</button>
</div>
</div>
<div class="row">
<div class="col-5 offset-1">
<div class="row">
<div class="col-2 px-0">
<p> LOW </p>
</div>
<div class="col-10">
<input type="text" id="price3">
</div>
</div>
</div>
<div class="col-2 offset-1 ">
<button type="reset" class="">CLEAR</button>
</div>
</div>
<div class="row">
<div class="col-5 offset-1">
<div class="row">
<div class="col-2 px-0">
<p> CLOSE </p>
</div>
<div class="col-10">
<input type="text" id="price4">
</div>
</div>
</div>
</div>
</div>
</div>
</form>
<table class="mt-5 table table-striped table-borderless table-main">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"> Classic</th>
<th scope="col">WOODIES</th>
<th scope="col">CAMARILLA</th>
</tr>
</thead>
<tbody>
<tr>
<td> Resistance 4 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> Resistance 3 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> Resistance 2 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> Resistance 1 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> PIVOT POINT </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> SUPPORT 1 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> SUPPORT 2 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> SUPPORT 3 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td> SUPPORT 4 </td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>
<form id="myForm" onsubmit="send_form(); return false;" action="" method="POST">
<table id="test">
<thead>
<tr>
<th class="test-1">1</th>
<th>2</th>
</tr>
</thead>
<tbody>
<tr>
<td>3</td>
<td>4</td>
</tr>
</tbody>
</table>
</form>
как я писал без input и она не работаеть , что изменет jq не знаю может бистрея напишу я счас тока учусь
$("#rezult").click(function() {
$('.test-1').html("#campivot.price2.val + #campivot.price2.val");
})
|
Цитата:
|
| Часовой пояс GMT +3, время: 15:37. |