I have an apex:repeat that runs through a large list of items. Currently we have a number of buttons that allow the user to see the item details in a new window, launch the item in a new window, view a certificate (in a new window) if the item has been completed and remove the item using a PageReference in the customController (in some circumstances).

This all looks a bit busy on screen so I want to put them all in a selectOption. I can render the items when I want them rendered but I cannot make the items active. Any ideas?

Below is an example details button:

<apex:outputPanel rendered="{!curr_i.item.RecordType.DeveloperName == 'Item'}" >
<apex:outputLink value="{!$Page.Details}?id={!curr_i.item.Id}&type=Thing" target="_blank" ><img src="{!URLFOR($Resource.Container, 'img/info24.png')}" title="ITEM DETAILS" alt="" /></apex:outputLink>

An example page reference call:

    <apex:outputPanel rendered="{!curr_i.item.RecordType.DeveloperName == 'Item'}" >
<apex:outputPanel rendered="{!curr_i.item.assignment.CreatedBy.id == currentUserId}">
    <apex:outputLink value="javascript:void(0);"
               onclick="if(confirm('Are you sure you want to permanently remove this item?')){remove('{!curr_i.item.Assignment.ID}','module');}else{return false;}"><img class="btn" src="{!URLFOR($Resource.Container, 'NewIcons/button_delete.png')}" title="REMOVE" alt="" />
  • What do you mean by "make the items active"?
    – Keith C
    May 19, 2014 at 20:18
  • Can you share some of the VF as well?
    – AlphaBravo
    May 19, 2014 at 20:21
  • By Active I mean I cannot work out how to get the selectOptions do what I need.
    – SeanGorman
    May 19, 2014 at 20:29
  • Is it that you want to open a popup window when a selection is made (instead of having a list of buttons)? Or are you looking to do something within the page containing the select list (a much bigger change)?
    – Keith C
    May 19, 2014 at 20:48
  • There are different actions for each of the selections. Launch, details, review and view cert open their respective pages. Remove is a page reference that returns NULL. I want to keep each of the behaviours but just call them when the option is clicked in the dropdown rather than have a set of buttons.
    – SeanGorman
    May 19, 2014 at 21:05

1 Answer 1


If you want to open the (existing) pages in a popup window when a selection is made you can use code like this:

        <apex:selectList size="1" onchange="selectChange(this);">
            <apex:selectOption itemLabel="--None--" itemValue=""/>
            <apex:selectOption itemLabel="ABC" itemValue="/apex/A?id=123"/>
            <apex:selectOption itemLabel="XYZ" itemValue="/apex/A?id=456"/>
function selectChange(select) {
    window.open(select.value, '_blank');

where instead of the above hard coded apex:selectOptions you would create then in your apex:repeat loop.

  • One question though: how will the pageReference be handled here?
    – SeanGorman
    May 20, 2014 at 15:50
  • @SeanGorman I just hard-coded some strings; you can still use {!$Page.Details}?id=... expressions for the itemValues. (This never goes to the controller - just redirects the browser.)
    – Keith C
    May 20, 2014 at 16:10
  • Another problem I have is that not all of the commands are window.open. I have tried to send 2 params or use str.split/str.substring but neither work in my visualforce page. Any ideas?
    – SeanGorman
    May 21, 2014 at 15:32
  • @SeanGorman I don't really follow; if you can't achieve some logic in Visualforce you can probably do it in JavaScript. But I suggest you post a new specific question if you remain stuck.
    – Keith C
    May 21, 2014 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .