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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -