javajavascriptjspscriptlet

Pass multiple arguments to javascript function from JSP scriptlet out.println


out.println("<button type='button' class='button' onClick='addProgressGoal(" + g.getGoalProgress() + g.getGoalID() + g.getTargetValue() + ")'>Add Progress</button>");

How can I pass three seperate values in the addProgressGoal as just using + is obviously just sending across one value of g.getGoalProgress(), g.getGoalID() and g.getTargetValue() added together.

Here is my function:

        function addProgressGoal(progress, id, target) {

For some reason I just cannot seem to send all three across in valid code


Solution

  • Is that what you want ?

    out.println("<button type='button' class='button' onClick='addProgressGoal(" + g.getGoalProgress() +", "+ g.getGoalID() +", "+ g.getTargetValue() + ")'>Add Progress</button>");
    

    Commas between parameters ?