www.webdeveloper.com
Results 1 to 4 of 4

Thread: Converting form text box into dropdown for php beginner

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Posts
    2

    Converting form text box into dropdown for php beginner

    Hi,

    I am new to php and trying to convert a wordpress form text box to a dropdown list, which then shows the value selected on a different page. I have the code and the text box showing but I do not know how to change the input form to have a dropdown as normally the html would sit under the <form> option.

    I would like the dropdown to show the following values for "Condition"=:

    New
    Used
    Other

    The code for the page that the value displays on is as follows:

    <?php echo $condition; ?>


    This is the text form I need to change to a dropdown:

    <li>
    <h2><?php echo __('Condition', 'AuctionTheme'); ?>:</h2>
    <p><input type="text" size="10" name="condition" class="do_input"
    value="<?php echo get_post_meta($pid, 'condition', true); ?>" /> <?php do_action('AuctionTheme_step3_after_condition_field'); ?></p>
    </li>


    Can someone give me a clue in the right direction? thanks

  2. #2
    Join Date
    Sep 2012
    Posts
    14
    this is what I would use for the html for the drop down list.

    HTML Code:
    <span><label for='condition'>Condition (/label>
    <select name="condition" id="condition">
    <option value="new">New</option>
    <option value="used">Used</option>
    <option value="other">Other</option>
    </select></span>
    Michael

  3. #3
    Join Date
    Oct 2012
    Posts
    2
    Where would I inset the code, I am guessing it fits in like this?


    <li>
    <h2><?php echo __('Condition', 'AuctionTheme'); ?>:</h2>
    <p><input type="dropdown" size="10" name="condition" class="do_input"
    value="<?php echo get_post_meta($pid, 'condition', true); ?>" />
    <span><label for='condition'>Condition (/label>
    <select name="condition" id="condition">
    <option value="new">New</option>
    <option value="used">Used</option>
    <option value="other">Other</option>
    </select></span>
    <?php do_action('AuctionTheme_step3_after_condition_field'); ?></p>
    </li>

  4. #4
    Join Date
    Sep 2012
    Posts
    14
    You can remove the
    HTML Code:
    <p><input type="dropdown" size="10" name="condition" class="do_input"
    The stuff between the select tags is the dropdown, and if you want to drop down to replace the input, remove the input part.

    Michael

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles