In below code i'm trying to get the values of individual inputs and on one single click display results as images. the code is working for individual input and from last to first I have only enabled fields which are DC Inputs, DC Outputs, Analog In and Analog Out. how can i make it to display images on single click after all the numbers enterd
DC Input: 16 DC Output: 16 Analog In: 8 Analog Out: 4
function toggleVisibility(id) {
var el = document.getElementById(id);
if (el.style.display=="block") {
el.style.display="none";
}
else {
el.style.display="block";
}
}
$(document).ready(function() {
$("#aibox").keyup(function(event) { // bind function called when key is released
$(".aibox").html("<input type=\"text\" id=\"aic\" placeholder=\"4-20mA\" size=\"10\"><br><input type=\"text\" id=\"aiv\" placeholder=\"0-10V\" size=\"10\">");
});
$("button").click(function() { // click method to call keydown() function
$("#aibox").keyup();
});
$("#aobox").keyup(function(event) { // bind function called when key is released
$(".aobox").html("<input type=\"text\" id=\"aoc\" placeholder=\"4-20mA\" size=\"10\"><br><input type=\"text\" id=\"aov\" placeholder=\"0-10V\" size=\"10\"> ");
});
$("button").click(function() { // click method to call keydown() function
$("#aobox").keyup();
});
});
function checkName() {
var text;
var di = document.getElementById("dibox").value;
if (di >= 16) {
text = "Use Digital Input Module";
document.getElementById('EZLGX-IO-16DCI').style.display='block'
return false;
}
var doo = document.getElementById("dobox").value;
if (doo >= 16) {
text = "Use Digital Output Module";
document.getElementById('EZLGX-IO-16DCOP').style.display='block'
return false;
}
var ainc = document.getElementById("aic").value;
var ainv = document.getElementById("aiv").value;
var aonc = document.getElementById("aoc").value;
var aonv = document.getElementById("aov").value;
//first If
if ((ainc && aonc <= 2) || (ainv && aonv <= 2)) {
text = "Use Two Combo Module";
document.getElementById('EZLGX-IO-4ACI4ACO').style.display='block';
document.getElementById('EZLGX-IO-8ACI').style.display='block';
return false;
// seconf if|| (ainv && aonv >= 3))
} else if (ainc && aonc >= 3) {
text = "Use Analog Input Current Module";
document.getElementById('EZLGX-IO-8ANI4ANOC').style.display='block';
return false;
} else if (ainv && aonv >= 3) {
text = "Use Analog Input Voltage Module";
document.getElementById('EZLGX-IO-8ANI4ANOV').style.display='block';
return false;
// last if
} else {
text = "Waaay off..";
}
document.getElementById("demo").innerHTML = text;
}
<script src="http://ift.tt/2nYZfvi"></script>
<table width="815" border="0" cellspacing="1" cellpadding="2">
<tbody>
<tr>
<td rowspan="2"><strong>CPU</strong></td>
<td><label for="EZLGX-CPU-1UE">EZLGX-CPU-1UE</label> <input type="checkbox" name="finallevelusers[]" onChange="toggleVisibility('EZLGX-CPU-1UE');"/> </td>
<td colspan="3">CPU 500K words ladder memory, USB, Micro SD, Ethernet and 1 RS232/422/48 ports.</td>
</tr>
<tr>
<td><label for="EZLGX-CPU-2UE">EZLGX-CPU-2UE</label><input type="checkbox" name="finallevelusers[]" onChange="toggleVisibility('EZLGX-CPU-2UE');"/> </td>
<td colspan="3">CPU 500K words ladder memory, USB, Micro SD, Ethernet and 2 RS232/422/48 ports.</td>
</tr>
<tr>
<td width="20%"><strong>DC Inputs</strong></td>
<td width="20%"><strong>DC Outputs</strong></td>
<td width="20%"><strong>AC Inputs</strong></td>
<td width="20%"><strong>AC Outputs</strong></td>
<td width="20%"><strong>High Speed Counter</strong></td>
</tr>
<tr>
<td valign="top" style="font-size:11px"><input type="text" id="dibox" size="10" onkeyup="sum();"/>
<!--<div class="dibox"></div>--></td>
<td valign="top" style="font-size:11px"><input type="text" id="dobox" size="10" onkeyup="sum();"/>
<!--<div class="dobox"></div>--></td>
<td valign="top" style="font-size:11px"><input type="text" id="acibox" size="10" onkeyup="sum();"/>
<div class="acibox"></div></td>
<td valign="top" style="font-size:11px"><input type="text" id="acobox" size="10" onkeyup="sum();"/>
<div class="acobox"></div></td>
<td valign="top" style="font-size:11px"><input type="text" id="hscbox" size="10" onkeyup="sum();"/><div class="hscbox"></div></td>
</tr>
<tr>
<td><strong>Anaog Input</strong></td>
<td><strong>Analog Output</strong></td>
<td><strong>Temperature Input</strong></td>
<td><strong>Relay Output</strong></td>
<td> </td>
</tr>
<tr>
<td valign="top" style="font-size:11px"><input type="text" id="aibox" size="10" onkeyup="sum();"/>
<div class="aibox"></div></td>
<td valign="top" style="font-size:11px"><input type="text" id="aobox" size="10" onkeyup="sum();"/>
<div class="aobox"></div></td>
<td valign="top" style="font-size:11px"><input type="text" id="tibox" size="10" onkeyup="sum();"/>
<div class="tibox"></div></td>
<td valign="top" style="font-size:11px"><input type="text" id="ribox" size="10" onkeyup="sum();"/>
<div class="ribox"></div></td>
<td valign="top" style="font-size:11px"></td>
</tr>
<tr>
<td colspan="5">
<div class="box" style=" overflow: auto; height: 275px;"><hr /><img id="EZLGX-CPU-1UE" src="http://ift.tt/2xPdG7j" style="display: none; float: left"/><img id="EZLGX-CPU-2UE" src="http://ift.tt/2xbwOzf" style="display: none; float: left"/><img id="EZLGX-IO-16DCI" src="http://ift.tt/2xPujj8" style="display: none; float: left"/><img id="EZLGX-IO-8ACI" src="http://ift.tt/2xbe0jy" style="display: none; float: left"/><img id="EZLGX-IO-4ACI4ACO" src="http://ift.tt/2xPdHrT" style="display: none; float: left"/><img id="EZLGX-IO-16DCOP" src="http://ift.tt/2xbcjT7" style="display: none; float: left"/><img id="EZLGX-IO-16DCON" src="http://ift.tt/2xPdIvX" style="display: none; float: left"/><img id="EZLGX-IO-4DCOP4RLO" src="http://ift.tt/2xbyZCG" style="display: none; float: left"/>
<img id="EZLGX-IO-8RLO" src="http://ift.tt/2xPdJ2Z" style="display: none; float: left"/>
<img id="EZLGX-IO-8ACO" src="http://ift.tt/2xbKdY8" style="display: none; float: left"/>
<img id="EZLGX-IO-8ANI4ANOV" src="http://ift.tt/2xPdK73" style="display: none; float: left"/>
<img id="EZLGX-IO-8ANI4ANOC" src="http://ift.tt/2xbz09I" style="display: none; float: left"/>
<img id="EZLGX-IO-4THIE" src="http://ift.tt/2xOP3rf" style="display: none; float: left"/>
<img id="EZLGX-IO-4RTD" src="http://ift.tt/2xbz1dM" style="display: none; float: left"/>
<img id="EZLGX-IO-HSCNT" src="http://ift.tt/2xPdLb7" style="display: none; float: left"/>
</div></td>
</tr>
</tbody>
</table>
<!--Analog In<input type="text" id="aic" placeholder="4-20mA" ><br><input type="text" id="aiv" placeholder="0-10V" ><br>
<br>
Analog Out<input type="text" id="aoc" placeholder="4-20mA" ><br><input type="text" id="aov" placeholder="0-10V" ><br><br>-->
<button id="plc" onclick="checkName()">Check Name</button>
<p id="demo"></p>
Aucun commentaire:
Enregistrer un commentaire