₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,329,444 members, 8,440,631 topics. Date: Tuesday, 07 July 2026 at 10:46 AM

Toggle theme

Please What Am I Missing Here? - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersPlease What Am I Missing Here? (485 Views)

1 Reply

Please What Am I Missing Here? by Emusan(op): 11:33pm On Aug 02, 2015
This is the first part of the code and it's working fine when I run it (I mean the first SELECT BOX [for makes] works perfect).
<?php
$makes = array('Acura', 'BMW', 'Lexus', 'Toyota', 'Honda');

if(isset($_POST['submit']))
{ echo '<pre>'; print_r($_POST); echo '</pre>'; }
?>
<form action="" method="post">
<select id="makes" name="makes"><!-- Make sure to give the select box a id, this will make it much easier to target with jquery. -->
<?php
foreach($makes as $m){ echo '<option value="'.$m.'">'.$m.'</option>'; }
?>
</select>
<select id="models" name="models"><!-- Make sure to give the select box a id, this will make it much easier to target with jquery. -->
</select>
<input type="submit" name="submit" value="Submit">
</form>
BUT The Second SELECT BOX [for model] didn't work at all

This is the AJAX code:
<script>
$('#makes').change(function(){
var make = $(this).val();
$.post('select-request.php', {make:make}, function(data){
$('#models').html(data);
});
});
</script>
And this is the select-request.php
<?php
error_reporting(E_ALL);

$acura = array('Integra', 'TSX', 'MDX');
$bmw = array('1 Series', '3 Series', '5 Series', 'X5');
$lexus = array('ES300', 'GX470', 'GS350', 'LS400H');
$toyota = array('Venza', 'Camry', 'Corolla', 'Echo');
$honda = array('Pilot', 'Accord', 'Civic', 'Ridgeline');

if(isset($_POST['make']))
{
$model = strtolower($_POST['make']);

foreach($$model as $mo){ echo '<option value="'.$mo.'">'.$mo.'</option>'; }
}


?>
Please will the javascript/script tag be outside or inside of the FORM TAG?
What can I add to achieve what I want?

Thanks!
1 Reply

Am I The Only One Whose Domain Has Been Suspended By Domainking?Am I The Only One Experiencing This With Facebook?Adsense CTR Of 35% Am I Safe?234

How To Drive Huge Traffic To A WebsiteKnbnaija.com The Trending Entertainment Site In NigeriaHTML Tutorial I: Introduction To HTML