Hello, when I try to send some data through variables on click, it allows only those with integer values and not strings. This has happened while I apply onclick() from a popup page.
Below is the scenario;
var user_id = 1;
var fname = "Erick";
<a href="#" onclick="setData('+user_id+')">Send</a> //**WORKS**
<a href="#" onclick="setData('+fname+')">Send</a> //**DOES NOT WORK**
//sendData function
function setData(getValue) { ///-----When I user_id, everything works fine, When I send fname; no response
alert(''+getValue+'');
}
From any experienced Javascript/JQuery developer; any help?
Please note the following. When the below link is clicked as it’s OR with anything else that contains number values, no problem the postJobStart() function get reached with no issues.
Problem arises when the parsed variable let say:
var fname = “Trump”;
That way it throws an error: Uncaught ReferenceError: Trump is not defined at HTMLAnchorElement.onclick
Great idea, I was actually missing the delimiters, I had to define them again before posting; and gave them some delimiters as below
var fname = "'" + fname + "'";
var lname = "'"+lname+"'";
That worked fine. For numbers as you know, doesn’t matter whether there are delimiters or not, that’s why I was able to post number only. Thanks Dormilich.