/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@mbaldwinOct 02.2012 — this is what I would use for the html for the drop down list.

[code=html]
<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>
[/code]


Michael
Copy linkTweet thisAlerts:
@chicky365authorOct 03.2012 — Where would I inset the code, I am guessing it fits in like this?


<li>

<h2><?php echo __('Condition', 'AuctionTheme'); ?>:</h2>

<p><input [COLOR=#ff0000]type="[/COLOR][COLOR=#ff0000]dropdown"[/COLOR] size="10" name="condition" class="do_input"

value="<?php echo get_post_meta($pid, 'condition', true); ?>" />

[COLOR=#000080]<span>[/COLOR][COLOR=#ff8000]<label for='condition'>[/COLOR]Condition (/label>

[COLOR=#ff8000]<select name=[COLOR=#0000ff]"condition"[/COLOR] id=[COLOR=#0000ff]"condition"[/COLOR]>[/COLOR]

[COLOR=#ff8000]<option value=[COLOR=#0000ff]"new"[/COLOR]>[/COLOR]New[COLOR=#ff8000]</option>[/COLOR]

[COLOR=#ff8000]<option value=[COLOR=#0000ff]"used"[/COLOR]>[/COLOR]Used[COLOR=#ff8000]</option>[/COLOR]

[COLOR=#ff8000]<option value=[COLOR=#0000ff]"other"[/COLOR]>[/COLOR]Other[COLOR=#ff8000]</option>[/COLOR]

[COLOR=#ff8000]</select>[/COLOR][COLOR=#000080]</span>[/COLOR]

<?php do_action('AuctionTheme_step3_after_condition_field'); ?></p>

</li>
Copy linkTweet thisAlerts:
@mbaldwinOct 06.2012 — You can remove the
[code=html]
<p><input type="dropdown" size="10" name="condition" class="do_input"
[/code]


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
×

Success!

Help @chicky365 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...