Gossamer Forum
Home : Products : Gossamer Links : Discussions :

help adding css to dropdown box

Quote Reply
help adding css to dropdown box
Hi all,

I am using the following code to produce a dropdown box:

sub {
my $column = shift;
my $selected = shift;
my $table = $DB->table("Links");
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
return $form;
}

i was hoping someone could help me add css to this form object as i am trying to add the following to it: class="select"

Can you help.
Kirk




--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Hi,

Try this before the end;

Code:
$form =~ s|\Qtype="select"|type="select" class="select"|i;
return $form;

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
Hi andy,

i thried your code which looks like this now:

sub {
my $column = shift;
my $selected = shift;
my $table = $DB->table("Links");
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
$form =~ s|\Qtype="select"|type="select" class="select"|i;
return $form;
}

but it does not change or add the css.

any help.
Kirk


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Mmm.. and what does the HTML print out? (I'm just guessing your format Wink).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
hi

this is what gets printed out:

<select name="Offer_Advertising"><option value="">---</option><option value="Yes">Yes</option><option value="No">No</option></select>

thanks
Kirk



--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Hi,

Sorry, was too early in the morning <G>

Try this line;

$form =~ s|\Qselect name="\E(.*?)\"|select name="$1" class="select"|i;

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
hi

Thanks for all this help but it still does not work, maybe i am placing it in the wrong place can you confirm please:

sub {
my $column = shift;
my $selected = shift;
my $table = $DB->table("Links");
my %hash;
my $i = 0;
my $names = $table->form_names->{$column};
my $vals = sort $table->form_values->{$column};
for my $val (@$vals) {
$hash{$val} = $names->[$i++];
}
my $html = $DB->html($table, $IN);
my $form = $html->select({
name => "$column",
values => \%hash,
value => $selected });
return $form;
$form =~ s|\Qselect name="\E(.*?)\"|select name="$1" class="select"|i;

Thanks for taking the time to help.

kirk
}


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Mmm.. that should work :/ (its in the right place too)

Can you try this?

$form =~ s|select name=\"(.*?)\"|select name="$1" class="select"|si;

Hope that helps.

Cheres

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
sorry still not working Blush

unless i am missing something in the top part of the code, but the class is not being added to the form field at all.

btw: just wondering if it would be a lot more easier to use what the catergory dropdown box uses for example the code for that is:

<select id="select" name="CatLinks.CategoryID" class="select">
<%loop category_loop%>
<option value="<%escape_html ID%>"<%if selected%> selected="selected"<%endif%>>
<%'&nbsp;&nbsp;' x $CatDepth%>
<%Name%>
</option>
<%endloop%>
</select>

would there be a possiblity to use something like that.

kirk


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.

Last edited by:

mekro: Jul 18, 2005, 1:52 AM
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Mmm.. how are you editing the global? Are you using mod_perl?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
hi

noi am editing the global via the global page in the admin area.

kirk


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Hi,

Ok, I'm stumped then :( AFAIK, that line should work fine Crazy

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
ok thanks you for all your help i can live with not having the css on those boxes however if you have a little time i was hoping you could look at the code again and tell me what could be wrong as when i try o edit a link those boxes do not show the origanal selection for example if i choose yes in the dropdown box and when i go back to edit it it is blank.

Kirk


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
How are you calling the global? Sounds like it's not populating it correctly (<%global_name('Field',$Field)%>, or similar).

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
the code i am using to display the form field is: <%build_select_menu('Offer_Advertising',$Offer Advertising)%>

by the way i am using links 3.0.4 if that helps


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.

Last edited by:

mekro: Jul 18, 2005, 2:47 AM
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Ah.. possibly your problem then =)

Try;

<%build_select_menu('Offer_Advertising',$Offer_Advertising)%>

Note the extra _.

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] help adding css to dropdown box In reply to
Hi

thank you so much andy that sorted it right out YAYAYAYAYAY

again thanks for taking the time.

Kirk


--------------------------------------------------

Life isn't like a box of chocolates ... it's more like a jar of jalapenos. What you do today might burn your ass tomorrow.
Quote Reply
Re: [mekro] help adding css to dropdown box In reply to
Glad that worked Cool

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!