Hi,
I'm trying to get my head a round a part of a site i'm working on, it's simple but i can't figure it out.
all i want to do i when a user selects "Other" in a drop down menu a text box appears below.
i know it could be done in javascript but i need it in php really.
any help needed please
Thank You
James
Drop down menu problem
Moderator: General Moderators
Re: Drop down menu problem
You need to use JS:
<select onchange='this.form.submit()'> ...
And then an if statement in PHP
<select onchange='this.form.submit()'> ...
And then an if statement in PHP
Re: Drop down menu problem
so once the user changes the option a box would appear almost instantly?
here is the php i have so far
and the html to go with it
could you give me an example??
Thanks
James
here is the php i have so far
Code: Select all
<?php
if (payment.value == "other")
{echo "<tr><td>Other:</td> <td class='input'><input type='text' name='other' /></td></tr>";}
{echo "<input type='hidden' name='other' value='N/A' />";}
?>Code: Select all
<td>Payment:</td><td class="input"><select name="selection">
<option>--Please Select--</option>
<option value="zero">zero</option>
<option value="one">one</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="four">four</option>
</select></td>
</tr>Thanks
James
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
Re: Drop down menu problem
i don't have time to answer your question right now but i hope you know that "php" you posted is well...not php. Looks like a combo of Javascript and PHP?
Re: Drop down menu problem
yeah i know it's not actual php
but i'm new to it and am still learning unfortunately
i've tried to outline what i am trying to do (with no idea on how to start it)
if you could give it a look sometime and let me know i'd be very greatful
Thanks
James
but i'm new to it and am still learning unfortunately
i've tried to outline what i am trying to do (with no idea on how to start it)
if you could give it a look sometime and let me know i'd be very greatful
Thanks
James
Re: Drop down menu problem
Moved to clientside.
Re: Drop down menu problem
I'll give a quick example before I call it a day:
Your form:
Your form:
Code: Select all
<form method="post" action="<?php echo $_SERVER['php_self']; ?>" name="papa">
<select name="selection" onchange='this.form.submit()'>
<option vals...
</select>
<?php
if(isset($_POST['papa'])) {
//show my textfield
}
?>