Gossamer Forum
Home : Products : DBMan : Customization :

combobox with redirect

Quote Reply
combobox with redirect
Hi there,

I use the modification list categories which search the database and then include these in a html page. (list categories isn't using db.cgi because of include)

This is working fine. But now i want those categories show in a combobox width redirect and not as text with redirect. Is there anyone who has a solution?

The list categorie script is show below

thanks Marcel;

#!/usr/bin/perl

#############################################################
# Number of Records v1.0
# records.cgi
# (C)1999 Anthro TECH, L.L.C
#
http://www.anthrotech.com/
#
info@anthrotech.com
#
# Will put a number of categories and sub-categories on
# a static web page.
#
# If you have any questions about using this script, please
# contact Anthro TECH, L.L.C at
support@anthrotech.com or
# post your questions on Gossamer-Threads Support Forum,
# which is located at:
#
#
http://www.gossamer-threads.com/scripts/forum/
############################################################################

############################################################################
# INSTRUCTIONS
#
# 1) Make sure that your perl path in the first line is correct.
#
# 2) Make sure that you have the correct path for your default.cfg
# file in the "require" line.
#
# 3) Save this file in your /cgi-bin/ directory under your DBMAN directory.
#
# 4) Change the permission of this file to: 755 or -rwxr-xr-x
#
# Owner : Read, Write, Execute (RWX)
# Group : Read, Execute (RX)
# Everyone: Read, Execute (RX)
#
# 5) This script is called via Server Side Includes (SSI) with the
# following codes in a file (.shtml or .html) that can have SSI:
#
# <!--#exec cgi="/cgi-bin/dbman/records.cgi"-->
#
#############################################################################

# Field Name to List (like Categories or Types)
$cat_name = 'merk';

# DB Setup ....
# Change the db_setup variable to your db name
# Set this to the same as you have in db.cgi
$db_setup = 'shopping';

# UID Setup....
# Set this up to the uid variable in your db.cgi file
# Should be set as default to allow anyone to view records in this
# Category.
$db_uid = 'default';

# Required Files to make this file work.
require "shopping.cfg";

# This needs to be the same setting in the db.cgi file
$db_script_path = "";

# Script Link URL
$db_script_link_url = "$db_script_url?db=$db_setup&uid=$db_uid";

for ($i = 0; $i <= $#db_cols; $i++) {
if ($db_cols[$i] eq "$cat_name") {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
&cgierr("No $cat_name field defined");
}
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $!");
if ($db_use_flock) {
flock(DB, 1);
}
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
if ($fields[21] eq 'Aanbieding') { # Change the 2 to match the field number you want to search
@values = split (/\Q$db_delim\E/o, $fields[$fieldnum]);
foreach $value (@values) {
if (!(grep $_ eq $value, @selectfields)) {
push (@selectfields, $value);
}
++$count{$value};
}
}
}
close DB;

foreach $field (sort @selectfields) {
$sfield = &urlencode($field);
print qq|<a href="$db_script_link_url&$&view_records=1&ID=*&$cat_name=$sfield&categorie=aanbieding&sb=1&so=descend" target="body"><font face="Tahoma" size="2" color="#000000">$field</font></a><br>|;
}

sub get_date {
# --------------------------------------------------------
# Returns the date in the format "dd-mmm-yyyy".
# Warning: If you change the default format, you must also modify the &date_to_unix
# subroutine below which converts your date format into a unix time in seconds for sorting
# purposes.

my ($time1) = $_[0];
($time1) or ($time1 = time());

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day-$months[$mon]-$year";
}

sub join_encode {
# --------------------------------------------------------
# Takes a hash (ususally from the form input) and builds one
# line to output into the database. It changes all occurrences
# of the database delimeter to '~~' and all newline chars to '``'.

my %hash = @_;
my ($tmp, $col, $output);

foreach $col (@db_cols) {
$tmp = $hash{$col};
$tmp =~ s/^\s+//g; # Trim leading blanks...
$tmp =~ s/\s+$//g; # Trim trailing blanks...
$tmp =~ s/\Q$db_delim\E/~~/og; # Change delimeter to ~~ symbol.
$tmp =~ s/\n/``/g; # Change newline to `` symbol.
$tmp =~ s/\r//g; # Remove Windows linefeed character.
$output .= $tmp . $db_delim; # Build Output.
}
chop $output; # remove extra delimeter.
$output .= "\n"; # add linefeed char.
return $output;
}

sub split_decode {
# --------------------------------------------------------
# Takes one line of the database as input and returns an
# array of all the values. It replaces special mark up that
# join_encode makes such as replacing the '``' symbol with a
# newline and the '~~' symbol with a database delimeter.

my ($input) = shift;
my (@array) = split (/\Q$db_delim\E/o, $input, $#db_cols+1);
foreach (@array) {
s/~~/$db_delim/g; # Retrieve Delimiter..
s/``/\n/g; # Change '' back to newlines..
}
return @array;
}

sub urlencode {
# --------------------------------------------------------
my($toencode) = @_;
$toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
$toencode=~s/\%2F/\//g;
return $toencode;
}


sub array_to_hash {
# --------------------------------------------------------
# Converts an array to a hash using db_cols as the field names.
#
my ($hit, @array) = @_;
my ($i);
return map { $db_cols[$i] => $array[$hit * ($#db_cols+1) + $i++] } @_;
}


sub cgierr {
# --------------------------------------------------------
# Displays any errors and prints out FORM and ENVIRONMENT
# information. Useful for debugging.

if (!$html_headers_printed) {
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
print "<PRE>\n\nCGI ERROR\n==========================================\n";
$_[0] and print "Error Message : $_[0]\n";
$0 and print "Script Location : $0\n";
$] and print "Perl Version : $]\n";
$db_setup and print "Setup File : $db_setup.cfg\n";
$db_userid and print "User ID : $db_userid\n";
$db_uid and print "Session ID : $db_uid\n";

print "\nForm Variables\n-------------------------------------------\n";
foreach $key (sort keys %in) {
my $space = " " x (20 - length($key));
print "$key$space: $in{$key}\n";
}
print "\nEnvironment Variables\n-------------------------------------------\n";
foreach $env (sort keys %ENV) {
my $space = " " x (20 - length($env));
print "$env$space: $ENV{$env}\n";
}
print "\n</PRE>";
exit -1;
}