Gossamer Forum
Home : Products : DBMan : Customization :

Jump to URL from Select field

Quote Reply
Jump to URL from Select field
How can i build a selectfield, that can do a jump to an URL.

I need a tag like this:

<SELECT NAME="GoMenu" ONCHANGE="jumpLink()" language="JavaScript"><OPTION SELECTED VALUE>Select a link<OPTION VALUE="$URLfromDB">$NAMEfromDB</SELECT></FORM><script language="JavaScript">function jumpLink(){ var a = document.jump.GoMenu.options[document.jump.GoMenu.selectedIndex].value +""; if(a != ''){ if(parent!=self){ var f = self; while(f!=window.top){ f = f.parent; } if(a.indexOf("://")!=-1){ f.body.window.location.href = a;}else{ window.top.location.href = a; } }else{ window.top.location.href = a; } document.jump.GoMenu.selectedIndex=0; } }</script>

I need a new Sub in my script like this:

sub build_quicklinks {
# --------------------------------------------------------
# Builds a SELECT field from URL with Go-Menu.

my ($column, $value, $name) = @_;
my (@fields, $field, @selectfields, @lines, $line, $ouptut);
my ($fieldnum, $found, $i) = 0;

$name || ($name = $column);

for ($i = 0; $i <= $#db_cols; $i++) {
if ($column eq $db_cols[$i]) {
$fieldnum = $i; $found = 1;
last;
}
}
if (!$found) {
return "error building select field: no fields specified!";
}

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 (!(grep $_ eq $fields[$fieldnum], @selectfields)) {
push (@selectfields, $fields[$fieldnum]);
}
}
close DB;

$output = qq|<SELECT NAME="GoMenu" ONCHANGE="QuicklinksLink()" language="JavaScript"><OPTION>---|;
foreach $field (sort @selectfields) {
($field eq $value) ?
($output .= "<OPTION SELECTED>$field") :
($output .= "<OPTION value=$URL>$field");
}
$output .= "</SELECT>";

return $output;

}

Please give me the code for the mod.

Thank you very much

KAI

Subject Author Views Date
Thread Jump to URL from Select field kai 2294 Aug 8, 2000, 2:42 AM
Thread Re: Jump to URL from Select field
JPDeni 2230 Aug 8, 2000, 3:17 AM
Thread Re: Jump to URL from Select field
kai 2234 Aug 8, 2000, 3:53 AM
Thread Re: Jump to URL from Select field
JPDeni 2202 Aug 8, 2000, 4:01 AM
Thread Re: Jump to URL from Select field
kai 2193 Aug 8, 2000, 4:09 AM
Thread Re: Jump to URL from Select field
JPDeni 2214 Aug 8, 2000, 4:10 AM
Thread Re: Jump to URL from Select field
kai 2193 Aug 8, 2000, 4:15 AM
Thread Re: Jump to URL from Select field
JPDeni 2208 Aug 8, 2000, 4:26 AM
Post Re: Jump to URL from Select field
kai 2185 Aug 8, 2000, 5:37 AM