내 페이지에 #add 및 #items 테이블이 두 개 있습니다. #add에는 단일 행의 입력이 있습니다. #items에 여러 행이 있습니다. 나는 입력을 데이터베이스에 저장하고있다. #add는 버튼을 클릭하면 저장되지만, #items는 흐리게 저장됩니다.다른 ID를 포함한 ID 별 jQuery selector 문제
문제는 #add 입력이 흐림 효과를 줄이려고한다는 것입니다. 아래에서 사용하는 선택기는 #item 테이블 입력뿐만 아니라 #add 테이블 입력에서도 작동합니다. 여기
코드의 샘플입니다 (필요하다면 나는 소스 파일에 링크 할 수 있습니다) : 당신의 선택이 잘못된 요소를 따기 수 있습니다처럼$("#items tbody tr td input:not('[name=\"ext\"]')").live('focus',function() {
$(this).attr("readonly",false);
$(this).select();
curEdit = $(this).val();
var name = $(this).attr('name');
if (name == 'item') {
$(this).alphanumeric();
} else if (name == 'tag') {
$(this).alphanumeric({allow:" "});
} else if (name == 'desc') {
$(this).alphanumeric({allow:".,-()/ "});
} else if (name == 'qty') {
$(this).numeric();
} else if (name == 'cost' || name == 'list' || name == 'disc' || name == 'unit' || name == 'ext') {
$(this).numeric({allow:"."});
}
}).live('blur',function() {
$(this).attr("readonly",true);
if (curEdit != $(this).val()) { // only update on changes
var col = $(this).parent().prevAll().length;
var query = "action=edit&id="+$(this).parents('tr').attr('rel');
if (col == 1 || col == 10) { $(this).val($(this).val().toUpperCase()); } // format ITEM and GSA
if (col > 4 && col < 10) { $(this).val(formatCurrency($(this).val())); } // format COST, LIST, DISC, UNIT, and EXTENDED
if (col == 3) { $(this).val(ucEach($(this).val())); }
if (col > 3 && col < 10 && col != 5) {
var qty = $(this).parents('tr').find("[name='qty']").val();
var list = $(this).parents('tr').find("[name='list']").val();
var disc = $(this).parents('tr').find("[name='disc']").val();
if ($(this).attr('name') != "unit") {
var unit = formatCurrency(list * (1-(disc/100)));
$(this).parents('tr').find("[name='unit']").val(unit);
} else {
disc = formatCurrency(((list - $(this).val())/list)*100);
$(this).parents('tr').find("[name='disc']").val(disc);
}
unit = $(this).parents('tr').find("[name='unit']").val();
var ext = formatCurrency(qty * unit);
$(this).parents('tr').find("[name='ext']").val(ext);
query = query + "&field[]=qty&val[]="+qty+"&field[]=list&val[]="+list+"&field[]=unit&val[]="+unit+"&field[]=disc&val[]="+disc+"&field[]=ext&val[]="+ext;
} else {
query = query + "&field="+$(this).attr('name')+"&val="+$(this).val();
}
$.post("itemsdb.php", query, function(data) {
if (data.res == "fail") {
alert("There was a problem saving this item."+data.error);
}
},"json");
}
});
html을 보지 않고 말하기가 어렵습니다. –
ID가 # #있는 테이블이 #items 테이블의 서브 테이블을 추가합니까? 또한 ID #items를 가진 또 다른 캡슐화 요소가있을 수 있습니까? – Keith