So I don't want to add another code in my controller class.

Is there a way I can accomplish this?

I have an actionFunction named makeEditable

<apex:actionFunction name="makeEditable" action="{!dispEdit}" reRender="pbt" />

I have an outputpanel with onclick attribute

'alert(/'Unable to edit this field/')')
}" > 

the onclick is not working. Am I doing it wrong?

Please help me.


  • 1
    Bring the developers tools console and check for errors Jul 21, 2014 at 10:20

1 Answer 1


When trying to generate JavaScript in Visualforce, you can check the results by using your browser's "Inspect Element" feature and should look at your browser's JavaScript console too for errors. (See e.g. How do I start to debug my own Visualforce/JavaScript?)

Your Visualforce is emitting:


rather than some valid JavaScript (assuming commit is a JavaScript variable) such as e.g.:

onclick="makeEditable(true || true || commit)"

You need something like this:

function unableToEditAlert() {
    alert('Unable to edit this field');
'makeEditable(' + IF(ISBLANK(fdsw.fds.Forecast_User__c), 'false', 'true') + ' || ' + IF(ISBLANK(fdsw.fds.User_Role__c), 'false', 'true') + ' || commit)',

The alert is awkward because there doesn't seem to be a way (in this context) to escape the quotes in Visualforce in a way that results in valid JavaScript in the generated HTML. Hence the additional function.

  • oh by the way the argument in the makeEditable function is only a 1 whole String value. The pipeline in between is only a splitter.
    – mdechavez
    Jul 22, 2014 at 2:16

You must log in to answer this question.

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