CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    May 2007
    Posts
    19

    Defaulting a Value of a Text Input Field

    I've got the following script. It allows a user to input a quantity, then the new price is updated. But there seems to be a code error (in that is doesn't update for the new price).

    Can anyone see where the error might be?

    Code:
    <?php
    if(isset($_POST["quantity"]))
    	$quantity = settype($_POST["quantity"], "integer");
    else
    	$quantity = 1;
    
    $item_price = 10.99;
    printf("%d x item = $%.2f",
    	$quantity, $quantity * $item_price);
    ?>
    <FORM ACTION="buy.php" METHOD=POST>
    Update quantity:
    <INPUT NAME="quantity" SIZE=2
    value =<?php echo $quantity;?>">
    <INPUT TYPE=SUBMIT VALUE="Change quantity and re-calculate price">
    </FORM>
    Last edited by PeejAvery; May 28th, 2008 at 07:59 AM. Reason: Added code tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured