which data from list?

Discussion in 'JavaScript' started by jacka, May 30, 2007.

  1. #1
    Hi
    I am trying to display a list of items from database, and would like the know how can I find out which item from the list the user has chosen to change?

    This is my unsuccessful attempt which doesn't work

    When a user clicks the done button, I would liek to send the itemId and the new entered quantity to a javascript, but can not figure out how to select the chnaged item
    Any help will be most welcome.
    here is part of the code:


    <?php


    while($row = mysql_fetch_array($result))
    {
    // Increment the total cost of all items

    $totalCost += ($row["qty"] * $row["price_each1"]);
    ?>
    <tr>
    <td width="7%" height="25">
    <font face="verdana" color="black" align="center">



    <input size="7" name="<?php echo $row["itemId"];?>" type="number" value="<?php echo $row["qty"];?>" onClick="UpdateQty(<?php


    echo $row["itemId"];?>, <?php echo $new_qty ;?>)">




    </font>
    </td>


    <td>


    <input name="check" type="submit" value ="Done" >
    etc.etc.

    ........
    function UpdateQty(a,b)
    {
    itemId=a;
    newQty=b;
    document.location.href = 'cartnew.php?action=update_item&id='+itemId+'&qty='+newQty;
    }
     
    jacka, May 30, 2007 IP