Jump to content

another dynamic menu issue


dlyles

Recommended Posts

Thank you.

I am trying to create a dependant drop down menu where when the user selects a group, a list of models comes up based on that group.  I got this code from another site and modified it, but can't get it to work.  Any ideas?

THE HEAD TAG
[code]

var ajax = new sack();

function getmodelList(sel)
{
var GroupCode = sel.options[sel.selectedIndex].value;
document.getElementById('dhtmlgoodies_model').options.length = 0; // Empty model select box
if(GroupCode.length>0){
ajax.requestFile = 'getmodelinfo.php?GroupCode='+GroupCode; // Specifying which file to get
ajax.onCompletion = createCities; // Specify function that will be executed after file has been found
ajax.runAJAX(); // Execute AJAX function
}
}

function createCities()
{
var obj = document.getElementById('dhtmlgoodies_model');
eval(ajax.response); // Executing the response from Ajax as Javascript code
}



[/code]
THE BODY
[code]
$query = "SELECT * FROM groups";
$result = mysql_query($query) or die ("query 1 failed");
$count = mysql_num_rows($result);


while ($row = mysql_fetch_array($result)) {
echo '<option value="'.$row['GroupID'].'">'.$row['GroupName'].'</option>';
}
echo '</select>';
[/code]
LASTLY, HERE'S THE getmodelInfo.php
[code]
if(isset($_POST['dhtmlgoodies_model'])  AND  isset($_GET['dhtmlgoodies_model'])){ 
  $yr = mysql_real_escape_string($_POST['dhtmlgoodies_group']);
 

$query = "SELECT * FROM models WHERE GroupID=$yr";
$result = mysql_query($query) or die ("query 1 failed");
$count = mysql_num_rows($result);


while ($row = mysql_fetch_array($result)) {
echo '<option value="'.$row['ModelID'].'">'.$row['ModelName'].'</option>';
}
echo '</select>';[/code]
and.... where did you get your example from?  Because you're not doing anything with the response, you don't have an area in your Body that you have set for updating (unless you're not showing the entire thing), and you're not handling the response correctly.

Honestly, it looks like there's a bunch of custom 3rd party code/functions that you're calling and we can't really help you with that.  If you want to scrap it and start over from scratch, we can help you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.