I want to set javascript variable with single quote. How it is possible. I am passing value to my function as parameter. and I am using this value to retrieve value of checkbox. So my problem is that if I am alerting value then it give me 'user' instead of 'sanjay' Here 'sanjay' is my value which is I am passing to parameter. And this will use to retrieve value of checkbox document.getElementById.
function single(user){
var abc = '\' user \'';
alert(abc);
return false;
var chksingle = document.getElementById(abc).checked;
alert(chksingle);
return false;
if (userlist() === false)
{
return false;
}
else
{
document.tallyexport.method = "post";
document.tallyexport.action = "checksingle.php";
document.tallyexport.submit();
}
}
Use string concatenation. The way you are doing it right now has user
as part of the actual string, not using the variable.
var abc = "' " + user + " '"
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