Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Get Value from Custom Select

$
0
0

Replies: 0

Hi WordPress,
I’ve got a custom post type setup with various custom attributes as inputs that work fine. I am trying to setup a custom value as a dropdown but I can’t seem to get the selected value. It’s for an age dropdown for ‘years’ and ‘months’

functions.php:

<p><label>Age:</label><br />
  <select name="months">
<?php
    foreach (range(0,11) as $months)
    {
        ?>
<option name="months" value="<?php echo $months;?>"><?php echo $months . ' Months';?></option>
        <?php
    }
?>
</select>
<select name="years">
<?php
    foreach (range(0,18) as $years)
    {
?>
<option name="years" value="<?php echo $years;?>"><?php echo $years . ' Years';?></option>
        <?php
    }
?>
</select></p>
function stats(){
  global $post;
  $months = $custom["months"][0];
  $years = $custom["years"][0];
function save_details(){
  global $post;
  update_post_meta($post->ID, "years", $_POST["years"]);
  update_post_meta($post->ID, "months", $_POST["months"]);
}

This works with other fields like inputs but it does not work for the selection from my dropdown. You can select a value but it is not saved. Any help is appreciated. Thank you.


Viewing all articles
Browse latest Browse all 59525

Trending Articles