php - Add dynamic value to a hidden form field -
i'm having contact form field named, addons select options
it's code
<?php foreach ($addons $options) { ?> <option value="<?php echo $options->addon_name; ?>"><h5><?php echo $options->addon_name; ?></h5></option> <?php } ?>
every addon have it's unique price. can fetch through $options->addon_price; added addon name in contact form i'm getting it's name once user submits form. likewise, need addon price without creating new field , asking users select price in dropdown.
any ideas ?
you can use following trick:
<?php foreach ($addons $options) { ?> <option value="<?php echo $options->addon_name.','.$options->addon_price; ?>"> <h5><?php echo $options->addon_name; ?></h5> </option> <?php } ?>
add price name in value of dropdown , after submitting page can string name , price , can split ,
using explode function it:
$pieces = explode(",", $str);
and can use price , name $name = $pieces[0]
, $price = $pieces[1]
.
Comments
Post a Comment