I want to pass the variable with space as parameter in onclick function. This is my table value with space :"file name sample"
echo '<input type=checkbox name=".$next." id=".$next." onclick=my1(this.form,this.checked,".$cid.",'".$vfet['file_name']."','".$id."');>';
script code
echo ('<script>
function my1(a,ischeck,cid,file,eid)
{
alert("welcome");
alert("select"+ischeck);
alert("file"+file);
}
</script>');
file value is passed nicely if the value has no space.
Make the html legal and put double quotes around the onclick value - at the moment the space is making the browser think it is a separate attribute.
You are also mixing up your single and double quotes a bit:
echo '<input type="checkbox" name="'.$next.'" id="'.$next.'" onclick="my1(this.form,this.checked,'.$cid.',\''.$vfet['file_name'].'\',\''.$id.'\');">';
just try
"'.$cid.'"
and not ".$cid."
or with the '\\'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.