1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What property inside the form can I use to assign this index string [‘size’]

Discussion in 'PHP' started by co.ador, Feb 10, 2010.

  1. #1
    I have this database field that used as the form input value '. $variety['price']. ' I also have a '. $variety['size']. ' database field that carry the name of the product but I don't know what another form input property to use to assign this size database field as a value to the input form property?

    I feel like I have run out of properties to carry more values to other values beside price to cart.php.

    Thank you the script is as below.

    <form action="cart.php" method="post">
    foreach($product['varieties'] as $variety){ 
    echo'<input style="width:10px; margin-left:9px; " name="price[]" type="checkbox" value="' . $variety['price']. '"  />';
    }
    </form>
    PHP:
     
    co.ador, Feb 10, 2010 IP
  2. Brandon.Add.On

    Brandon.Add.On Peon

    Messages:
    178
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If you are trying to encapsulate it from the user try using a hidden input field. If you want the user to see it, put it in a visible text input field.

    Using the text input approach:

    
    <form action="cart.php" method="post">
    <?php
    
    foreach($product['varieties'] AS $variety)
    {
    	echo'<input style="width:10px; margin-left:9px; " name="price[]" type="checkbox" value="' . $variety['price']. '"  /> <br />';
    	echo'<input style="width:10px; margin-left:9px; " name="size[]" type="text" value="' . $variety['size']. '"  />';
    }
    
    ?>
    </form>
    
    Code (markup):
    or using the hidden input field approach:

    
    <form action="cart.php" method="post">
    <?php
    
    foreach($product['varieties'] AS $variety)
    {
    	echo'<input style="width:10px; margin-left:9px; " name="price[]" type="checkbox" value="' . $variety['price']. '"  /> <br />';
    	echo'<input style="width:10px; margin-left:9px; " name="size[]" type="hidden" value="' . $variety['size']. '"  />';
    }
    
    ?>
    </form>
    
    Code (markup):
     
    Brandon.Add.On, Feb 10, 2010 IP