Title: Require selected dropdown list title-name as variable
Last modified: September 1, 2016

---

# Require selected dropdown list title-name as variable

 *  [oldcrusty](https://wordpress.org/support/users/oldcrusty/)
 * (@oldcrusty)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/require-selected-dropdown-list-title-name-as-variable/)
 * I’m new to WordPress but fairly ok with php. I want to select an item from a 
   dropdown list of Titles and send it to another page for processing with if(isset(
   $Post[‘title’]) etc.
    However when I select an item title from the dropdown and
   hit send, it takes me to the actual page of that title itself with links forward
   and back to all the other pages in the Title list. I’ve tried a few things like
   attempting to make a string of the selected Title, and getting the list using
   get_post_meta(), but the end result is always the same as above. If anyone can
   just point me in the right direction that would be fantastic.
 * _[ Moderator note: code fixed. Please wrap code in the backtick character or 
   [use the code button](http://codex.wordpress.org/Forum_Welcome#Posting_Code).]_
 *     ```
       <form action="<?php bloginfo('url'); ?>/booking-times" method="post">
       <div class="style">
       		<select class="style" id="style" name="style">
       		<option value="" selected="selected">Select preferred style</option>
   
       		<?php
       		$args = array(
       			'post_type' => 'style',
       			'meta_key' => 'style_type',
       			'orderby' => 'menu_order',
       			'order' => 'ASC',
       			'post_status' => 'publish'
       		);
       		$style_listing= new WP_Query( $args ); ?>
       <?php if ( $style_listing->have_posts() ) : ?>
       			<?php while ( $style_listing->have_posts() ) : $style_listing->the_post(); ?>
       				<option id="<?php the_id(); ?>" class="style"  value=" <?php the_title(); ?>"><?php the_title(); ?></option>
       			<?php endwhile; ?>
       		<?php endif; ?>
   
       		</select>
       		</div><!--end div class style-->
       					</div><!--end div id style-->
   
       							<div id="submit">
       								<input class="data-submit" type="submit" name="submit" value="Next">
       							</div><!--end submit-->
       							</form>
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Sakar U Khatiwada](https://wordpress.org/support/users/sakaruk/)
 * (@sakaruk)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/require-selected-dropdown-list-title-name-as-variable/#post-7600859)
 * What are you trying to achieve is not clear here.
 * According to the code it always sends the form data to the page yourwebsite.com/
   booking-times after the button Next is pressed I dont see any send button there
   too
 *  Thread Starter [oldcrusty](https://wordpress.org/support/users/oldcrusty/)
 * (@oldcrusty)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/require-selected-dropdown-list-title-name-as-variable/#post-7600914)
 * Thank you very much Sakar for your reply. Sorry for not being clear. I have a
   booking form for a hair styling salon with inputs for selecting a date and a 
   style-title. Using just plain php (without wordpress) it’s simple to send the
   inputs to another page (booking_times.php) where the date, and style-title values
   can be collected eg:-
 *     ```
       if(isset($_POST['submit'])) {
       	$style = $_POST['style-title'];
       }
       ```
   
 * I’m trying to attempt the very same thing in a wordpress site. In my wordpress
   version of the same site the date will pass through to the booking_times.php 
   page exactly the same as in a php only site but the selected style from the style
   dropdown list does not, instead it goes to
    the page with the Title of style-
   title. I’m basically trying to convert a php only site to a wordpress site and
   I’m at a bit of a loss as to where I need to do some research next.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/require-selected-dropdown-list-title-name-as-variable/#post-7600951)
 * For the style title and date to both be sent to a WP page, the fields need to
   be within the same form. I’m only seeing the style-title field in your form, 
   no date.
 * With WordPress, you can request PHP pages directly like booking_times.php, but
   that page cannot use any WP functions because the page either is not initializing
   the WP environment, or it is doing it wrong. There’s a limited number of ways
   to request code be run in the WP environment. This article explains:
    [http://glennmessersmith.com/pages/wpenviro.html](http://glennmessersmith.com/pages/wpenviro.html)
 *  Thread Starter [oldcrusty](https://wordpress.org/support/users/oldcrusty/)
 * (@oldcrusty)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/require-selected-dropdown-list-title-name-as-variable/#post-7600965)
 * Thank you very much bcworkz for that usefull info. Looks like I have some digging
   to do, but it’s the best way to learn.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Require selected dropdown list title-name as variable’ is closed to new
replies.

## Tags

 * [dropdowns](https://wordpress.org/support/topic-tag/dropdowns/)
 * [linking](https://wordpress.org/support/topic-tag/linking/)
 * [lists](https://wordpress.org/support/topic-tag/lists/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 4 replies
 * 3 participants
 * Last reply from: [oldcrusty](https://wordpress.org/support/users/oldcrusty/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/require-selected-dropdown-list-title-name-as-variable/#post-7600965)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
