I'm trying to pass a value from an inputfield to other pages. Unfortunately the value is not retrieving/not working, so hopefully someone could help me with this.
page.php
<form action="" id="testform" method="post">
<select size="1" class="dropdown">
<?php // dropdown options (pages)
$Args = array ('cat' => 1);
$loop = new WP_Query( $Args );
while($loop->have_posts()) : $loop->the_post(); ?>
<option value="<?php echo get_permalink(); ?>">
<?php the_title(); ?>
</option>
<?php endwhile; ?>
</select>
<input id="year" name="year" type="text" value=""/><!--The value that will be passed to another page -->
<input class="button" name="submit" type="submit" value="ENTER"/>
</form>
On submit - goto location (Form action)
$(".button").click(function(){
var linkadress = $('.dropdown option:selected').val();
window.location = linkadress;
return false;
});
Footer.php
THE PROBLEM: passing the value (field id = year )
var yearfield = "<?php echo htmlspecialchars($_POST['year']); ?>";
alert(yearfield); // Currently no value is passed
**Build on Wordpress platform. The form is visible on all the pages. When the form is sumbitted the 'year' value should be retrieved on the new page (the chosen dropdown location). The rest of the code is working fine.
Aucun commentaire:
Enregistrer un commentaire