Hi all,
I need to do modify the form where the user need to check some boxes and after that display in the textfield just the childres items that are in the parents select .
this is the code where i did the autocomplete but i need to add the parent select any idea? im really stuck, thanks
function cookbook_ingredients_xhr($name) {
$name = urldecode($name);
$query = "SELECT nid, title FROM node WHERE status = 1 AND type = 'ingredient'";
$query_args = array();
// Check language
if (module_exists('i18ntaxonomy')) {
$query .= " AND language IN('','%s')";
$query_args[] = i18n_get_lang();
}
// Look for id if name is numeric
if (is_numeric($name)) {
$query .= " AND nid = %d";
$query_args[] = $name;
}
else {
$names = explode(' ', $name);
foreach ($names as $name) {
$query .= " AND title LIKE '%%%s%%'";
$query_args[] = $name;
}
}
$query .= " ORDER BY title";
$result = db_query_range($query, $query_args, 0, 6);
$ingredients = array();
while ($ingredient = db_fetch_object($result)) {
$ingredients[] = $ingredient;
}
print drupal_to_js($ingredients);
}
Attachment | Size |
---|---|
ingredient.png | 83.98 KB |