All pastes #374040 Raw Edit

Mine

public php v1 · immutable
#374040 ·published 2007-02-27 05:05 UTC
rendered paste body
<div align="right"><?php  //Vocabulary ID$vid=5;$formname="Name of the form.. put anything here";$vocabulary = db_query("SELECT term_data.name, term_data.tid FROM term_data WHERE term_data.vid=$vid ORDER BY term_data.weight, term_data.name ASC");//Populate array with url / name$options[''] = 'My select drop down title';if (arg(1)) {    //if we have an argument make it the default    //and place "Show all" in the drop down   $default_value = "/tickets/" . arg(1);   $options['/tickets/'] = 'Show All';}while ($term = db_fetch_object($vocabulary)) {        	$options['/tickets/'.$term->tid] = $term->name;}//Build dropdown select//If we try to build OnChange directly it gets mangled, so put in array to confuse the forms api$form['category'] = array(  '#type' => 'select',  '#name' => $formname,  '#id' => $formname,  '#title' => '',  '#default_value' => $default_value,  '#options' => $options,  '#description' => '',  '#multiple' => $multiple = FALSE,  '#required' => $required = FALSE,  '#attributes' => array('onChange' => "top.location.href=document.getElementById('$formname').options[document.getElementById('$formname').selectedIndex].value"),);//Output the formprint drupal_get_form('Company_dropdown', $form);?></div>