I have a list of pages generated by Wordpress within a drop down, on click, how can submit the form and goto the page that was selected?
<form id="work" action="" method="post">
<select name="work">
<?php $pages = get_pages(array('child_of' => '15', 'sort_column' => 'menu_order'));
foreach($pages as $post) {
setup_postdata($post);
$fields = get_fields(); ?>
<option class="work-dropdown" value="<?php echo the_permalink(); ?>"><?php echo the_title(); ?></option>
<?php } wp_reset_query(); ?>
</select>
</form>
I tried this jquery but I'm not sure if that's correct and what to put in the action:
<script type="text/javascript">
jQuery(document).ready(function( $ ) {
$('.work-dropdown').change(function() {
$('#work').submit();
});
});
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…