Gossamer Forum
Home : Products : Links 2.0 : Customization :

How to create valid lists using build_select_field

Quote Reply
How to create valid lists using build_select_field
The code in Links for build_select_field produces links that are not valid HTML
What I want is to have different entries for the value and for the text that is displayed.
So value could be Category, but the text would be something different, possibly from a different field.

So
<option value="Markup">
Markup Selection
</option>

rather than
<option>Markup
Quote Reply
Re: [astro] How to create valid lists using build_select_field In reply to
I ran into that problem, too. Look in db_utils.pl, find the sub build_select_list routine, and near the end of it, change the code to resemble this:

# Below was highy modified to be valid XHTML --
$output = qq|<select name="$name"|;
$mult ?
($output .= qq| multiple="multiple" size="$altcatsize">\n|) :
($output .= qq|>\n|);
$output .= qq|<option value="---">---</option>\n|;
foreach $field (@fields) {
$values{$field} ?
($output .= qq|<option value="$field" selected="selected">$field</option>\n|) :
($output .= qq|<option value="$field">$field</option>\n|);
}
$output .= "</select>\n";
return $output;
}


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] How to create valid lists using build_select_field In reply to
Thanks.
Just to add to this, I also wanted to be able to have the Displayed text different from the Category (which has underscores in the name)

So I did the following:
Code:
$output = qq|<select name="$name"|;
$mult ?
($output .= qq| multiple="multiple" size="$altcatsize">\n|) :
($output .= qq|>\n|);
$output .= qq|<option value="---">Please Select One</option>\n|;
foreach $field (@fields) {
$ValueText = &build_clean($field);
$values{$field} ?

($output .= qq|<option value="$field" selected="selected">$ValueText</option>\n|) :
($output .= qq|<option value="$field">$ValueText</option>\n|);
}
$output .= "</select>\n";
return $output;
}