"<button onclick=editRecords('" + partId + "')>Add Quantity</button>";
If I pass the partId
string without spaces, it's working fine. But if I pass 'MRF 01'
, it gives me
Uncaught SyntaxError: Unexpected token ILLEGAL.
Why is this and how can I fix that?
Use
whenever you pass space as a function parameter. If you are using js to generate onclick, use encodeURIComponent.
"<button onclick=editRecords('" + encodeURIComponent(partId) + "')>Add Quantity</button>";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With