Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Creating Drop Down Arrays
Old 11-30-2005, 04:41 PM Creating Drop Down Arrays
Average Talker

Posts: 27
Location: CT
Trades: 0
Sorry to have to post this topic, because I'm sure its been posted before, but I scoured this site, and google as well and cant seem to find an easy demo example.

I'm VERY new to php, and learn something new everyday, (and hopefully very soon will move on to mySQL too) and want to know how to make dropdown arrays for my fathers used car website, where if someone selects Acura from a dropdown menu, Acura models will display in another dropdown, (CL, TL, Integra, ect).

Can anyone provide me with a working example, with like 2 or 3 choices from the first menu, and like 2 or 3 choices from the second menu, then once I see a working example I could figure out how to edit it to fit my needs.

I'd GREATLY appreciate it!
DBookatay is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-02-2005, 10:37 AM
Average Talker

Posts: 27
Location: CT
Trades: 0
Anyone?
DBookatay is offline
Reply With Quote
View Public Profile
 
Old 12-03-2005, 07:31 AM
Average Talker

Posts: 26
Trades: 0
Excuse my lack of knowledge of cars, but do you mean something like...

Code:
<?php
$car1 = array ("model1", "model2", "model3");

echo '<form><select>';

foreach ($car1 as $car) {
echo '<option>'.$car.'</option>';
}

echo '</select></form>';
?>
__________________
Liway Hosting - FREE packs - 5,000MBs Space / 125,000MBs Bandwidth, cPanel with all features enabled and unlimited!

Please login or register to view this content. Registration is FREE

My Site ->
Please login or register to view this content. Registration is FREE
Starcraftmazter is offline
Reply With Quote
View Public Profile Visit Starcraftmazter's homepage!
 
Old 12-09-2005, 01:40 AM
Skilled Talker

Posts: 62
Trades: 0
PHP Code:
<html>

<body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<select name="options" onBlur="javascript:this.form.submit();">
<option value="1">Option</option>
<option value="2">Option</option>
<option value="3">Option</option>
</select>
</form>

<?php if (count($_POST)>0) { ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="options" value="<?php echo $_POST['options']; ?>" />
<select name="options2" onBlur="javascript:this.form.submit();">
<?php
  
switch($_POST['options']) {
    case 
"1":
?>
<option value="1">1 - Option</option>
<option value="2">1 - Option</option>
<option value="3">1 - Option</option>
<?php
    
break;
    case 
"2":
?>
<option value="1">2 - Option</option>
<option value="2">2 - Option</option>
<option value="3">2 - Option</option>
<?php
    
break;
    case 
"3":
?>
<option value="1">3 - Option</option>
<option value="2">3 - Option</option>
<option value="3">3 - Option</option>
<?php
    
break;
  }
?>
</select>
</form>
<?php ?>

</body>

</html>
I'd be hesitant to rely on the onBlur event, but there you go.
__________________

Please login or register to view this content. Registration is FREE
danlefree is offline
Reply With Quote
View Public Profile Visit danlefree's homepage!
 
Reply     « Reply to Creating Drop Down Arrays
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.63028 seconds with 12 queries