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]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.