Drop down list value for "Other" option

Discussing Html . Code , Software , other

Moderators: macek, egami, gesf

User avatar
wmdrumaizi
New php-forum User
New php-forum User
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia
Contact:

Drop down list value for "Other" option

Postby wmdrumaizi » Sun May 18, 2003 8:03 pm

Hi guys; I need a little help; I have a drop down list:

Code: Select all

<select name="car">
   <option>-Select Car-</option>
   <option value="MAZDA">MAZDA</option>
   <option value="OPEL">OPEL</option>
   <option value="Nissan">Nissan</option>
   <option value="Volvo">Volvo</option>
   <option value="">Other</option>
</select>


What I want is if user select the last option i.e. 'Other', they are required to specify the car they requested by entering car model in a text box (named car_other). Could someone please tell me how to insert this second value into a Mysql table.

F.Y.I I'm using php, Mysql and apache

User avatar
WiZARD
Moderator
Moderator
Posts: 1257
Joined: Thu Jun 20, 2002 10:14 pm
Location: Ukraine, Crimea, Simferopol
Contact:

Re: Drop down list value for "Other" option

Postby WiZARD » Mon May 19, 2003 2:47 am

interestin it's hard to change?:

Code: Select all

<select name="car">
   <option>-Select Car-</option>
   <option value="MAZDA">MAZDA</option>
   <option value="OPEL">OPEL</option>
   <option value="Nissan">Nissan</option>
   <option value="Volvo">Volvo</option>
   <option value="other">Other</option>
</select>

liquedus
php-forum Active User
php-forum Active User
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Postby liquedus » Mon May 19, 2003 6:31 am

here some pseudo code for it

$query = "INSERT INTO ...";
$query .= "some more";
if(car_is_other_condition) $query .= "value from text box";

that help?

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Mon May 19, 2003 7:11 am

IF I understand what you mean,
you want the script to use a text box value if the person has selected "Other"?

If that's right,

<select name="car">
<option>-Select Car-</option>
<option value="MAZDA">MAZDA</option>
<option value="OPEL">OPEL</option>
<option value="Nissan">Nissan</option>
<option value="Volvo">Volvo</option>
<option value="">Other</option>
</select>

That's fine, leave it as-is.

Code: Select all

if ($car == "") { $car = $textbox with car in; }
$query = "INSERT into blah blah blah";

using the variable $car as your final value...

Andrew
Last edited by bezmond on Mon May 19, 2003 7:13 am, edited 1 time in total.

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Mon May 19, 2003 7:12 am

That code goes in the submit PHP coding area by the way.

Andrew


Return to “HTML Basics”

Who is online

Users browsing this forum: No registered users and 0 guests