Find your content:

Search form

You are here

How to pass more than one parameter to an actionFunction?

 
Share
<a href="javascript:;" onclick="if(confirm('Are you sure?'))
    {remove2('{!oplist.lineNumber1}');}">

<img src="{!$Resource.Red_Cross}" alt="Remove" title="Remove" /></a>



<apex:actionFunction name="remove2" action="{!removeoppline2}" reRender="thePB">
    <apex:param name="name" value="rono" assignTo="{!proname}" />
</apex:actionFunction>

I also want to send record id like {!oplist.opplineNo.id} on remove image click..how can i send both line number and recordid simontaneously....pl help me with it

UPDATED

for(OpportunityLineItem l:lOpp) {    
    wrapperopllist.add(new linenumberclass(l,m));
    m++;
}

  <apex:repeat value="{!wrapperopllist}" var="oplist" rows="{!PageSize}" id="wrapid">

    <tr height="50px">
        <td class="Tdtext">{!oplist.lineNumber}
            <div id="{!rno}" style="display:none">
                <apex:image value="{!$Resource.Warning_Image}" height="15px" id="im" />
            </div>
        </td>
        <td class="Tdtext">{!oplist.oppLineNo.PricebookEntry.Product2.name}

        </td>



        <td class="Tdtext">
            <apex:inputField value="{!oplist.oppLineNo.Exclusive__c}" />
        </td>
        <td class="Tdtext">
            <apex:inputField value="{!oplist.oppLineNo.TV_Everywhere__c}" />
        </td>
        <td class="Tdtext">
            <apex:inputField value="{!oplist.oppLineNo.Description}" />
        </td>
        <td class="Tdtext">

            <a href="javascript:;" onclick="if(confirm('Are you sure?')){remove1('{!oplist.oppLineNo.id}','{!oplist.lineNumber}');}">
                                   <img src="{!$Resource.Red_Cross}" alt="Remove" title="Remove" />
                             </a>
            <apex:variable value="{!rno+1}" var="rno" />
        </td>

    </tr>

</apex:repeat>

<apex:actionFunction name="remove1" action="{!removeoppline}" reRender="thePB">
    <apex:param name="id" value="rno" assignTo="{!deleteid}" />

    <apex:param name="name" value="rno" assignTo="{!proname}" />
<apex:actionFunction/>


remove method

public void removeoppline() {
    system.debug('==='+wrapperopllist);
    System.debug('"""""""""""'+deleteid);
    wrapperopllist.remove(proname-1);

    for(Integer i = proname-1; i < wrapperopllist.size(); i++) {
        wrapperopllist[i].linenumber=proname;
        proname++;
    }

Attribution to: Mik

Possible Suggestion/Solution #1

StackExchange Tip: You should update your question (and ensure future ones) to something more generic like 'How to pass more than one parameter to a actionFunction?'. And try to provide as much background as you can about the information being displayed/manipulated.

Answer: Assuming you can obtain the Id via the 'oplist' binding, and given what you've shared about this on a previous quesiton, this should work just fine...

remove2('{!oplist.lineNumber1}', '{!opList.oppLineNo.Id}');

Then add a second apex:param like so...

<apex:actionFunction name="remove2" action="{!removeoppline2}" reRender="thePB">
  <apex:param name="name" value="rono" assignTo="{!proname}"/>
  <apex:param name="id" value="rono" assignTo="{!proid}"/>
</apex:actionFunction>

NOTE: Make sure to expose 'proid' as a new controller variable, much like you have 'proname'.

The important thing with actionFunction parameters is to pass them in the correct order, although they are named, the name does not really get used. As you can see above, it's the order they are passed.


Attribution to: Andrew Fawcett
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4267

My Block Status

My Block Content