Problem with jQuery selector by ID including other IDs -


i have 2 tables on page: #add , #items. #add has single row of inputs. #items has multiple rows. i'm saving inputs database. #add supposed save on button click whereas #items saves on blur.

the problem #add inputs trying save on blur well. selector i'm using below working on #add table inputs #items table input.

here sample of code (i can link source file if need be):

$("#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()) { // 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 , gsa         if (col > 4 && col < 10) { $(this).val(formatcurrency($(this).val())); } // format cost, list, disc, unit, , 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 problem saving item."+data.error);             }         },"json");     } }); 

it sounds selector might picking incorrect elements. try running selector in javascript console of browser:

$("#items tbody tr td input:not('[name=\"ext\"]')") 

then, examine object(s) returned , ensure match you're trying match.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -