Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » setting selected attribute for an <option>

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1061 Views
  • jcoby
    Avatar
    Community Member
    2 Posts

    setting selected attribute for an <option> Link to this post

    I'm trying to build a <select> manually with all of the children of a certain page. The code looks like:

    <% control ChildrenOf(case-studies) %>
              <% if ClassName = RedirectorPage %>
    <option value="$ContentSource.Link">$Title</option>
    <% end_if %>
    <% end_control %>

    How can I set the selected attribute if the current page is a child of the page being use for the <option>?

  • simon_w
    Avatar
    Forum Moderator
    467 Posts

    Re: setting selected attribute for an <option> Link to this post

    <% control ChildrenOf(case-studies) %>
    <% if ClassName = RedirectorPage %>
    <option value="$ContentSource.Link"<% if LinkOrSection = section %> selected="selected"<% end_if %>>$Title</option>
    <% end_if %>
    <% end_control %>

    Should do it.

  • jcoby
    Avatar
    Community Member
    2 Posts

    Re: setting selected attribute for an <option> Link to this post

    worked perfectly! thank you!

    1061 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.