1

I need to call an apex action inside HTML. I had completed my UI design in Visualforce page with the help of HTML, now i need to call my action from controller (Custom).

I am not sure how to insert the apex action inside HTML. I couldn't find any blog or solution for the same.

Please find the sample code below, I need to achieve the same.

<div class="WholeBoxSmallDiv" id="NewSmallDiv" style="display:none">
<table cellpadding="5" cellspacing="0" width="100%" border="0">
    <tr>
        <td width="5%"><img src="{!URLFOR($Resource.offerIMG)}"/></td>
        <td class="classBold">Search Offer</td>
    <apex:actionSupport event="onclick" action="{!searchList}" rerender="formId">
    <apex:param name="objType" assignTo="{!strObjectType}" value="Case"/>
    </apex:actionsupport>
    </tr>
</table>

But the code is not working.

Please let me know if anyone else have achieved the same.

2
  • Can you please post the code from your controller too? Aug 17 '15 at 4:22
  • On which html element you want the action? Aug 17 '15 at 5:53
1

You can do this thru Javascript

HTML -> call Javascript -> call Apex

Reference : JavaScript Remoting and Static HTML

Add JavaScript functions to the page as handlers to respond to user interaction. Use JavaScript remoting to call Apex @RemoteAction methods that retrieve records, perform DML, and so on.

and here's an example with code from salesforce developer docs

JS Remoting Example

4
  • Thank you , i am trying to call a Java script from HTML and then invoke an apex function. Aug 17 '15 at 6:43
  • Thanks for your time. I am trying to call apex action function from HTML through JAVA script. HTML--->JavaScript--->Apex Action. However this is not working. Currently the call is going till JavaScript but the action is not called. please find the scripts in my next comment. Aug 17 '15 at 6:49
  • 'Javascript : <script type='text/javascript'> function CheckoffersJavaScript() { Checkoffersmethod() ; alert('Entered Javascript') ; } </script> Apex action: <apex:actionfuntion name="Checkoffersmethod" action="{!checkOffersBasedOnEmailOrVIN}" status="mySaveStatus1" rerender="formId"> <apex:param name="objType" assignTo="{!strObjectType}" value="Case"/> </apex:actionfuntion> ' Aug 17 '15 at 6:50
  • HTML: '<div class="WholeBoxSmallDiv" id="NewSmallDiv" style="display:none"> <table cellpadding="5" cellspacing="0" width="100%" border="0"> <tr> <td width="5%"><img src="{!URLFOR($Resource.offerIMG)}"/></td> <td class="classBold" onclick="CheckoffersJavaScript">Search Offer</td> </tr> </table> </div> </body>' Aug 17 '15 at 6:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.