Ok, I've got a table with names, id's, and descriptions. What I would like to do is that when I select a name in a select box the description-text will shown in an textfield. This is what I've got now (It only outputs the dropdown menu):
--------------------------
----------
-
$question_one = array();
$question_one[] = array('id' => '2', 'text' =>ANSWER_DEFAULT);
$question_one_querry = tep_db_query("select sources_id, sources_name from " . TABLE_QUESTIONS . " where question_number =1 order by sources_name");
while($question_one_values
= tep_db_fetch_array($questi
on_one_que
rry)) {
$question_one[] = array('id' => $question_one_values['sour
ces_name']
,
'text' => $question_one_values['sour
ces_name']
);
}
echo tep_draw_pull_down_menu(''
, $question_one);
--------------------------
----------
The tep_draw_pull_down_menu function looks like this:
--------------------------
----------
function tep_draw_pull_down_menu($n
ame, $values, $default = '', $parameters = '', $required = false) {
$field = '<select name="' . tep_output_string($name) . '"';
if (tep_not_null($parameters)
) $field .= ' ' . $parameters;
$field .= '>';
if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$nam
e]);
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . tep_output_string($values[
$i]['id'])
. '"';
if ($default == $values[$i]['id']) {
$field .= ' SELECTED';
}
$field .= '>' . tep_output_string($values[
$i]['text'
], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';
}
$field .= '</select>';
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
return $field;
}
--------------------------
-..
Start Free Trial