Juniper567
Juniper567

Reputation: 37

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

Upvotes: 0

Views: 1686

Answers (2)

user13827818
user13827818

Reputation: 41

just put single apostrophe before and after the parameter value in the calling function example: onclick="addProgressGoal('abc','def');"

Upvotes: 0

Magador
Magador

Reputation: 644

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 ?

Upvotes: 1

Related Questions