php - Javascript [object HTMLSpanElement] -
<body onload="check(<?php echo($type);?>,<?php echo($bool);?>)"> #code... </body> function check(var1,var2) { alert(var1); if (var2 == true) { edit(var1); }; } # var1 string # var2 true/false boolean # var2 works fine, passes through false/true value without problems # var1 on other hand problem. hello everyone, i'm trying pass php variable javascript function. variable $type isset "email", this;
$data['type'] = "email"; but reason javascript function automatically picks value of email input instead of value assigned $type variable.
if set $type else, this;
$data['type'] = "random"; note: i've been trying alert(); value make sure it's correct value.
so if try alert(type); within javascript function , 'type' set doesn't exist in form, nothing happens.
if set 'type' exist in form(e.g. password, email) automatically alert(); value form inputs, , not value assigned $data['type'] in php function.
anyone got clue problem is?
try adding quotes around var1 :
<body onload="check('<?php echo($type);?>',<?php echo($bool);?>)">
Comments
Post a Comment