<body onload="check(<?php echo($type);?>,<?php echo($bool);?>)">
#code...
</body>
function check(var1,var2)
{
alert(var1);
if (var2 == true)
{
edit(var1);
};
}
# var1 is a string
# var2 is a true/false boolean
# var2 works just fine, passes through the FALSE/TRUE value without problems
# var1 on the other hand is the problem.
Hello everyone, i'm trying to pass PHP a variable into my javascript function. the variable $type isset to "email", like this;
$data['type'] = "email";
But for some reason the javascript function automatically picks the value of my email input instead of the value that i assigned to the $type variable.
If i set $type to something else, like this;
$data['type'] = "random";
Note: I've been trying to alert(); the value just to make sure it's the correct value.
So if i try to alert(type); from within the javascript function and 'type' is set to anything that DOESN'T exist in my form, nothing happens.
If i set 'type' do something that DOES exist in my form(e.g. password, email) it will automatically alert(); the value from my form inputs, and not the value i assigned to $data['type'] in my PHP function.
Anyone got a clue what the problem is?