calculate values on basis of text box entry
i have one row of text boxes which is generated with php loop and mysql id.
<input class="text_field1" id="<?php echo $i ?>" name="q_<?php echo $row['pid']; ?>"
type="text" style="width:150px" />
<input disabled="disabled" class="text_fieldD" id="p_<?php echo $row['pid'];
?>" name="p_<?php echo $row['pid']; ?>" type="text" value="<?php echo $row['pprice'] ?>" />
<input disabled="disabled" class="text_fieldD" id="t_<?php echo $row['pid']; ?>"
name="t_<?php echo $row['pid']; ?>" type="text" />
what i want is
when i enter any value in text box with class text_field1, i want to calculate total in text box name t_.... (qty * price ,p_....)
i try this code its works little bit but not all i want , my JQUERY code is
$('.text_field1').bind("focus blur change keyup", function(){
var $el = $(this);
var numPallets =IsNumeric1($el.val());
开发者_运维知识库 });
Thanks
I think this should work. I only binded it to keyup in this example:
$('.text_field1').keyup(function() {
var pid = $(this).attr("name").split("_")[1]; // row pid
var q = $(this).val() * 1;
var p = $("#p_"+pid).val() * 1;
$("#t_"+pid).val(q * p);
});
精彩评论