[tmp tables][list-databases][/tmp]
[perl table="[scratch tables]"]

	my @tables = split /\s+/, $Scratch->{tables};
	my $out;
	for(@tables) {
		$tables{$_} = [ $Db{$_}->columns() ];
	}
	$out = "<SCRIPT LANGUAGE=JAVASCRIPT>\n<!-- \n";

	foreach my $tab (sort keys %tables) {
		my $cols = $tables{$tab};
		my $row = (qq{ var ary_$tab = new Array ("('-- select column --', '', true,true)",});
		for(@$cols) {
			$row .= qq{"('$_')",\n};
		}
		$row =~ s/,$/);/;
		$out .= $row;
	}
	$out .= <<EOF;
function populateTable(table_options,column_options,selected) {
	var selectedArray = eval ( "ary_" + selected );
	var currentTable = 'products';
	var currentArray = eval ( "ary_" + currentTable );
	while (selectedArray.length < column_options.length) {
		column_options[(column_options.length - 1)] = null;
	}
	for (var i=0; i < selectedArray.length; i++) {
		eval("column_options[i]=" + "new Option" + selectedArray[i]);
	}
	var selectedKey = column_options[1].text;
	if (table_options[0].value == '') {
		table_options[0]= null;
    }
   return true;
}
// End -->
</SCRIPT>
EOF
[/perl]
