0

My function following values in parameter

function viewStudent(schoolName, fullName, class, rollnumber) {

}

Here are the values stored in student object.:

schoolName="St Joseph's School" 
fullName="xyz" 
rollNumber=2019,

While calling viewStudent I pass value as:

onclick="changeFormStatus('${studentValue.schoolName}','${studentValue.fullName}',
 '${studentValue.rollNumber}', '${studentValue.class}')"

But as the schoolName contains apostrophe, It is giving error of "missing )". Any Idea how I can handle this issue.

1 Answers1

2

use backtick(`) instead of apostrophe(') on parameters:

onclick="changeFormStatus(`${studentValue.schoolName}`,`${studentValue.fullName}`,
 `${studentValue.rollNumber}`, `${studentValue.class}`)"
zmag
  • 7,825
  • 12
  • 32
  • 42