CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
CGI.pm radio button doesn't support "id" ?

 



ningji
Novice

May 13, 2014, 3:12 PM

Post #1 of 10 (9450 views)
CGI.pm radio button doesn't support "id" ? Can't Post

id is used for CSS and JavaScript/jQuery (has to be unique in a page),

but in my perl 5.14.2, seems CGI.pm doesn't support "id" ?
am i missing something or ?

Thanks !


FishMonger
Veteran / Moderator

May 13, 2014, 4:50 PM

Post #2 of 10 (9416 views)
Re: [ningji] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

You should ALWAYS post the relevant code.

Did you specify the -labelattributes parameter?


FishMonger
Veteran / Moderator

May 13, 2014, 4:59 PM

Post #3 of 10 (9409 views)
Re: [ningji] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

In case you didn't understand what I was referring to, here's an example.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Pretty;

print header(),
start_html(),
radio_group(-name => 'group_name',
-values => ['eenie', 'meenie', 'minie'],
-default => 'meenie',
-labelattributes => { id => 'my_id' }),
end_html();



ningji
Novice

May 13, 2014, 5:04 PM

Post #4 of 10 (9405 views)
Re: [FishMonger] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

Thanks so much !

(the next time i'll remember to post my code)


FishMonger
Veteran / Moderator

May 13, 2014, 5:16 PM

Post #5 of 10 (9396 views)
Re: [ningji] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

I used the id attribute because that's what you referred to in your question, but in this case you should instead use the class attribute.


ningji
Novice

May 13, 2014, 5:16 PM

Post #6 of 10 (9395 views)
Re: [FishMonger] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

1 more question, in your example,
if i want each of the radio has its own id,
how should i write it ?

-labelattributes => { id => ['id1', 'id2'] }),



In Reply To
In case you didn't understand what I was referring to, here's an example.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Pretty;

print header(),
start_html(),
radio_group(-name => 'group_name',
-values => ['eenie', 'meenie', 'minie'],
-default => 'meenie',
-labelattributes => { id => 'my_id' }),
end_html();




(This post was edited by ningji on May 13, 2014, 5:18 PM)


FishMonger
Veteran / Moderator

May 13, 2014, 5:34 PM

Post #7 of 10 (9377 views)
Re: [ningji] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

You'll probably need to print each radio button individually.


ningji
Novice

May 13, 2014, 5:36 PM

Post #8 of 10 (9375 views)
Re: [FishMonger] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

tried to do that, but i only see radio_group(), not radio() ...

call it twice ?


In Reply To
You'll probably need to print each radio button individually.



(This post was edited by ningji on May 13, 2014, 5:38 PM)


FishMonger
Veteran / Moderator

May 13, 2014, 5:42 PM

Post #9 of 10 (9366 views)
Re: [ningji] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

So, use 3 radio groups with a single item.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Pretty;

my %labels;

print header(),
start_html(),
radio_group(-name => 'group_name',
-values => 'eenie',
-default => '',
-labelattributes => { id => 'id1' }),
radio_group(-name => 'group_name',
-values => 'meenie',
-default => '',
-labelattributes => { id => 'id2' }),
radio_group(-name => 'group_name',
-values => 'minie',
-default => '',
-labelattributes => { id => 'id3' }),
end_html();



ningji
Novice

May 13, 2014, 5:44 PM

Post #10 of 10 (9364 views)
Re: [FishMonger] CGI.pm radio button doesn't support "id" ? [In reply to] Can't Post

got it, thanks so much !


In Reply To
So, use 3 radio groups with a single item.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use CGI qw(:standard);
use CGI::Pretty;

my %labels;

print header(),
start_html(),
radio_group(-name => 'group_name',
-values => 'eenie',
-default => '',
-labelattributes => { id => 'id1' }),
radio_group(-name => 'group_name',
-values => 'meenie',
-default => '',
-labelattributes => { id => 'id2' }),
radio_group(-name => 'group_name',
-values => 'minie',
-default => '',
-labelattributes => { id => 'id3' }),
end_html();



 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives