I have idea for my program, and I see the solution in Stackoverflow, like this :
jQuery(function(){
var max = 3;
var checkboxes = $('input[type="checkbox"]');
checkboxes.change(function(){
var current = checkboxes.filter(':checked').length;
checkboxes.filter(':not(:checked)').prop('disabled', current >= max);
});
});
<script src="http://ift.tt/1V0HKB6"></script>
<input type="checkbox" value="true" />
<input type="checkbox" value="true" />
<input type="checkbox" value="true" />
<input type="checkbox" value="true" />
<input type="checkbox" value="true" />
<input type="checkbox" value="true" />
<input type="checkbox" value="true" />
that is show the serial number for each product and select by quantity input before.
I will show the flow programm. first input product who will be issued: picture add issued
name form input textbox for the product is pid
and for the quantity is qty
and then this is form after input issued:
this is result picture that I want
<%
String[] pid = request.getParameterValues("pid");
String[] qty = request.getParameterValues("qty");
for (int i = 0; i < pid.length; i++) {
int loop = Integer.valueOf(qty[i]);
try {
String sql = " select count(psn.SerialCombine)as jumlah from Products_SN psn where (psn.Issued_ID is null or psn.Issued_ID = '') and psn.ProductID='10101'";
ResultSet resultset4 = db.runSql(sql);
resultset4.next();
String sql2 = "SELECT S.ProductID,S.SerialCombine, P.ProductName FROM Products_SN S, Products P WHERE S.ProductID= P.ProductID AND (S.Issued_ID is null or S.Issued_ID = '') AND S.ProductID='"+pid[i]+"'";
ResultSet resultset2 = db.runSql(sql2);
resultset2.next();
while(resultset2.next()){
%>
<input type="checkbox" name='sn_id' value='<%=resultset2.getString("SerialCombine")%>'> <%= resultset2.getString("ProductName")%> <%= resultset2.getString("SerialCombine")%> <br>
<%
}
} catch (Exception e) {
System.out.println(e);
}
}
%>
But if i use this script it make all checkbox disable not for each product I want checkbox disable by quantity each product.
Aucun commentaire:
Enregistrer un commentaire