jquery metin akım değerini nasıl

0 Cevap php

I'm trying to compute a value from 2 given values quantity and price. I used the keyup event in jquery to compute the total from the current value of the qty and price. How will I be able to reference the current textbox which initiates the keypress event. And put the corresponding total to the assigned box.
Do you know of any jquery plugins that will make it easier for me to achieve the result.

<script type="text/javascript">
$(function(){

$('input[name^=qty]').keyup(function(){

    var curprice=$('input[name^=price]').val();
    var curqty=$('input[name^=qty]').val();
    var curtotal=curprice * curqty;

    $('input[name^=comp]').val(curtotal);
});




});

</script>

</head>
<body>




<?php
for($a=0;$a<=5;$a++){
    ?>


    Price:<input type="text" name="<?php echo 'price'.$a; ?>" value="<?php echo $a; ?>"/>
    Quantity:<input type="text" name="<?php echo 'qty'.$a; ?>" value="<?php echo $a; ?>"/>
    Computed:<input type="text" id="<?php echo 'a'.$a; ?>" name="<?php echo 'comp'.$a ?>" value="" />


    <?php
echo "<br/>";
}

?>




</body>
</html>

Heres a screenshot. alt text

Eğer daha fazla bilgi gerekiyorsa, teşekkür sormaya çekinmeyin.

0 Cevap