On 1/5/06, Peter Speltz <[EMAIL PROTECTED]> wrote:
> [%#
>
> =head2 set_selected
>
> Set which option in the select box element is selected based on value.
> "element" is an HTML::Element object of type select.
>
> =cut
>
> %]
>
> [% MACRO set_selected(element, value) BLOCK;
>     FOR opt IN element.content_list;
>
>         IF opt.attr('value') != value;
>             opt.attr('selected', undef);
>         ELSIF opt.attr('value') == value;;
>             opt.attr('selected', 'selected');
# BUG  Above line. add this in front "SET myval = " .
>             LAST;
>         END;
>     END;
> END;
> %]
>

Bug in above. It gets me every time.  Since HTML::Element returns a 
value when you change/set (not sure exact details) an attribute, you
get this phantom 'selected'  showing up on the page when using the
macro. Catch that value like this when you set attributes.   Above I
commented .

SET myval =  opt.attr('selected', 'selected');

--
pjs


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users

Reply via email to