₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,347,688 members, 8,528,825 topics. Date: Thursday, 03 December 2026 at 01:37 AM

Toggle theme

Please What Am I Missing Here? - Webmasters - Nairaland

Nairaland Forum › Science/Technology › Webmasters › Please What Am I Missing Here? (495 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? • 2 • 3 • 4

Who Is Gonna Teach Us How To Build Wapka Website On Nairaland • Cloudhost Webhosting • Prestad Server Are Scammer See What They Did To A Publisher That Earns $1,319.75