我在带有ddslick的WordPress插件中有一个选择菜单。我想传递所选选项的id并将表单发送到数据库,但是虽然它出现在html中,但是不会保存该值。投入手册时维护得很好。
<script type='text/javascript' src='http://g-page.co.il/wp-content/themes/g-page/js/jquery.ddslick.min.js'></script>
<div id="myDropdown">
<select id="demo-htmlselect">
<?php
$thumbnails = get_posts('numberposts=5');
foreach ($thumbnails as $thumbnail) {
$url = wp_get_attachment_url( get_post_thumbnail_id($thumbnail->ID) );
?>
<option value="<?php echo $thumbnail->ID;?>" data-imagesrc="<?php echo $url; ?>"
data-description="<?php echo $thumbnail->post_title;?>"><?php echo $thumbnail->post_title;?></option>
<?php } ?>
</select>
</div>
<?php
?>
<div class="wrap">
<form method="post" action="options.php">
<?php wp_nonce_field('update-options') ?>
<input type="text" name="main_art_id" size="45" value="<?php echo get_option('main_art_id'); ?>" />
</p>
<p><input type="submit" name="Submit" value="Store Options" /></p>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="ain_art_id" />
</form>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#myDropdown').ddslick({
onSelected: function(selectedData){
var cor_val = selectedData['selectedData']['value'];
$("input[name=main_art_id]").val(cor_val);
}
});
});
</script>
<?php
}