You need to sign in to do that
Don't have an account?
sylar2
dynamic addition of block and fields on a page
I am trying to create a page where i can have a package with two fields as services appearing by default.
It should look like:
Package 1:
Service: <Picklist> Service: <Picklist>
Cklick to ADD more services
<Adds one more line dynamically with option to add two more services just below it in the same page>
---------------------------------------------------------------------------------------------------------
Click to ADD more Package
Dont know how to work it out. Please Help
How are the values for services being stored? Are they stored as a related sObject to package?
Depending on how you store them depends on the implementation.
Services are just picklist fields... my custom sObject is Package..
Is this the same as the question posted on the apex discussion board? If so I've posted an answer over there. If not, what is different in this case?
I recently did a similar thing on one of my projects. my 'filters' variable is a list of objects that I defined as another class. the 'addFilter' function will add another item to the list and the 'removeFilter' will remove an item from the list. You could replicate this code to do pretty much the exact thing you desire.
<apex:pageBlock title="Competitive Intel - Basic" id="intelBlock">
<table border="1" cellpadding="5" cellspacing="10" id="filterTbl">
<tr>
<td>
<table cellpadding="2">
<caption><b>Filters</b></caption>
<apex:repeat value="{!filters}" var="curr">
<tr>
<td>
<apex:selectList value="{!curr.filterField}" size="1">
<apex:selectOptions value="{!items}" />
</apex:selectList>
</td>
<td>
<apex:selectList value="{!curr.filterType}" size="1">
<apex:selectOptions value="{!filterTypes}" />
</apex:selectList>
</td>
<td><apex:inputText value="{!curr.filterString}" /></td>
</tr>
</apex:repeat>
<tr>
<td>
<apex:commandLink action="{!addFilter}" value="Add Filter" style="color: blue;" rerender="intelBlock"/>
</td>
<td>
<apex:commandLink action="{!removeFilter}" value="Remove Filter" style="color: blue;" rerender="intelBlock" />
</td>
</tr>
</table>
</td>
</tr>
</table><br/>