Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,668 members, 7,955,423 topics. Date: Sunday, 22 September 2024 at 05:04 AM

Please What Am I Missing Here? - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Please What Am I Missing Here? (447 Views)

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)

(1) (Reply)

Please What Am I Missing Here? by Emusan(m): 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)

Naira Land AD Banner Designer Needed Asap / The Best Way To Carry Out Website Traffic Analysis / Micromax Has Launched Their Canvas Tab P680 With 3G Support

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.