Hi I am building Dynamic taxonomy Form from Ryan`s code
http://www.ubercart.org/jquery_dynamic_form/18

So
My first step is done:
</code>
$vid=2;$formname="taxonomy";
$vocabulary = db_query("SELECT term_data.name, term_data.tid,
term_data.language FROM term_data WHERE term_data.vid=$vid AND
term_data.language = '" . i18n_get_lang() . "' ORDER BY name");
$options[] = t('... '); // Initialise the Taxonomy array
//Populate array with taxonomy ID / name
while ($term = db_fetch_object($vocabulary)) {
$options[$term->tid] = $term->name;
}
//Build dropdown select
$form['taxonomy']['2'] = array(
 '#type' => 'select',
 '#name' => $formname,
 '#id' => 'class-box',
 '#title' => 'Jump Taxonomy',
 '#default_value' => '',
 '#options' => $options,
 '#description' => '',
 '#multiple' => $multiple = FALSE,
 '#required' => $required = FALSE,
 '#attributes' => array('onchange' => 'mod_class_fields(this.value);')
);
</code>
You can see two important things .
First is compatible with i18n and second after choice will open a new box.
Very Good!!

But after this I am into a Drupal Jquery tag:
<code>
drupal_add_js('
$(document).ready(function(){
 // Ready code here.
 if ($("#class-box").val() > 0)
   mod_class_fields($("#class-box").val(), 0);
});

function mod_class_fields(class_id, speed) {
 var cfields;
 if (speed == null)
   speed = "slow";

 switch (class_id) {
   case "3":
   cfields = "<div class=\"form-item\"><label for=\"edit-genre\">Genre:
</label><select name=\"genre\" class=\"form-select\" id=\"edit-genre\"
<option>Drama</option><option>Action</option><option>Sci-Fi</option></select></div>";
   break;

   case "2":
     cfields = "<div class=\"form-item\"><label for=\"edit-genre\">Genre:
</label><select name=\"genre\" class=\"form-select\" id=\"edit-genre\"
<option>Drama</option><option>Action</option><option>Sci-Fi</option></select></div>";
     break;
   default:
     cfields = "<div></div>";
 }

 if (class_id == "0")
   $("#class-fields").hide("slow").empty();
 else
   $("#class-fields").empty().append(cfields).show(speed);
}
', 'inline');
</code>
and I want in simple way
case "3":
"<div class=\"form-item\">
print drupal_render($form['taxonomy']['6']);
</div>";

I tried a lot of things but dont work. I am feeling could have something in
Jquery is crashing my ideas.

Who can help me?

--
Mário
[EMAIL PROTECTED]
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to