tom123
03-06-2006, 06:31 PM
Im using HTML::Template, if the user selects a table from a select box a cgi script retreives the tables fields, then returns to the html page displaying the selected tabel and its fields in another select box. Problem is the following code is displaying the selected table twice, i.e the unless statment dosent seem to be working. Please help, ive been pulling my hair out all weekend trying to fix it.
If user selected table dog then after cgi called the slecect box will display:
dog
dog
cat
mouse
etc..
######################html###################################
<td align="top"><i>Tables:</i></BR>
<select name="table" onchange="reload(this.form)">
<option value="<tmpl_var table_selected>" selected="true"><tmpl_var table_selected></option>
<tmpl_loop name="tables">
<tmpl_unless name="table_selected">
<option value="<tmpl_var table_name>"><tmpl_var table_name></option>
</tmpl_unless>
</tmpl_loop>
</select>
</td>
##################The cgi code#########################
# Create reference to each entry in @tables. Needed by template file data_selection.tmpl, to access data.
while(@tables)
{
my %my_tables;
$my_tables{table_name} = shift @tables;
push(@tables_ref,\%my_tables);
}
$session->param('tables', \@tables_ref);
If user selected table dog then after cgi called the slecect box will display:
dog
dog
cat
mouse
etc..
######################html###################################
<td align="top"><i>Tables:</i></BR>
<select name="table" onchange="reload(this.form)">
<option value="<tmpl_var table_selected>" selected="true"><tmpl_var table_selected></option>
<tmpl_loop name="tables">
<tmpl_unless name="table_selected">
<option value="<tmpl_var table_name>"><tmpl_var table_name></option>
</tmpl_unless>
</tmpl_loop>
</select>
</td>
##################The cgi code#########################
# Create reference to each entry in @tables. Needed by template file data_selection.tmpl, to access data.
while(@tables)
{
my %my_tables;
$my_tables{table_name} = shift @tables;
push(@tables_ref,\%my_tables);
}
$session->param('tables', \@tables_ref);