It would be nice if this macro was in the default templates macros - I've struggled how to work out how to manpiulate the html element objects in TT in the past.

The post I referred to was about extracting the html.element object from the original POST request - which was not pretty.

Does this kind of logic processing really belong in templates though? Shouldn't it be in mySearch : Exported {} or something?


On 6 Jan 2006, at 07:58, Peter Speltz wrote:

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


-------------------------------------------------------
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