I've scoured the internet (php forums mostly) to find a solution and have not turned up anything that actually works - hoping someone here can help......
I have a form that creates a dropdown list from specific pages and populates the value of the options based on info in a custom field. The dropdown works perfectly.
<select id="products" name="products">
<option selected value="null">Please Select Your Product</option>
<?php global $post;
$myposts = get_posts('orderby=title&order=ASC&post_type=page&post_parent=22&numberposts=-1');
foreach($myposts as $post) : ?>
<option value="<?php $sku = get_post_meta($post->ID, productsku, true); echo $sku ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
I have another hidden input on the same form that needs to have it's value populated based on the site visitor's selection from the dropdown list, but it's not as simple as passing the value from the selected option to the hidden input value, it actually needs to check for a second custom field from the same page as the selection.
<input type="hidden" name="location" id="location" value="<?php echo $othercustomfield ?>" />
So if the visitor selects a product from the dropdown list, I need to find what the value of the custom field (meta_key "location") is for that specific selection, and put it into the hidden input field.