【发布时间】:2014-01-08 15:35:17
【问题描述】:
我希望对我使用复选框的验证过程有所帮助。 我有两个问题:
问题 1: 我成功地在我的屏幕上显示了一个复选框项目(“f_mark”),但我需要将复选框显示为已标记。实际上复选框出现,但未选中(未标记)。 这是我的代码..
sys.HTP.p(
'<tr><td class="left"><a href="javascript:popUp2('''||apex_util.prepare_url('f?p=&APP_ID.:2:'||:app_session||':ADD:::P2_codigo_articulo:'||sys.htf.escape_sc(c1.codigo_articulo))||''',''700'',''400'');">' ||
'<input type="text" size="12" name="f_unit_price" value="' || TRIM(TO_CHAR(c1.precio,'999G999G990')) || '" readonly></td>' ||
'<td><input type="number" size="6" value="' || c1.cantidad_existencia || '" name="f_qty" min="1" max="9999" step="1"</td>' ||
'<td><input type="text" name="f_serie" value="' || c1.numero_serie || '" readonly></td>' ||
'<td class="left">' || sys.HTF.escape_sc(c1.descripcion_articulo) || '</a></td>' ||
'<td><input type="checkbox" name="f_mark" value="true"></td>' ||
'<td><input type="text" name="f_prod_id" size="1" value="' || sys.HTF.escape_sc(c1.codigo_articulo) || '" readonly></td>' ||
'</tr>');
问题 2: 我需要捕获复选框字段(“f_mark”)的值,并在复选框被选中时进行验证。这是我的代码,但它不起作用。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Totalizar</title>
<script type="text/javascript">
$(function () {
$("#Calculate").click(
// mueve el valor al campo de cantidad
function () {
var total = 0;
var total_qty = 0;
$("input[name=f_mark]").each(
function () {
var marcado = $(this).val();
var quantity = $(this).parents('tr').find("input[name=f_qty]").val();
var productId = $(this).parents('tr').find("input[name=f_prod_id]").val();
if (marcado == 'true') {
var price = $(this).parents('tr').find("input[name=f_unit_price]").val();
var serieId = $(this).parents('tr').find("input[name=f_serie]").val();
var prodtotal = (quantity * price);
total = total + prodtotal;
total_qty = total_qty + 1;
}
}
);
$('#printHere').html(decimalizer(total));
$('#printHereqty').html(total_qty);
}
);
提前感谢任何提示。
【问题讨论】:
标签: javascript jquery checkbox