please can somebody let me know how to do the following PHP in JavaScript. The vaibles in PHP are Parameters in Javascript. If all three Parameters are set then I would like a PHP script to execute:
<?php
if isset($nation,$service,$slider)
{
//execute php script
}
?>
Thanks for looking, and maybe helping!
To clear any confusion, I require all the PHP above to be converted into it JavaScript equivalent.
On top of this I would like a way of executing a PHP script within the JavaScript if all 3 Parameters are set.
Assuming none of your variables have a zero or null value, for example, if they're all strings, the shortest way to write variable checks is to just use them:
function blah (nation, service, slider)
{
if (nation && service && slider)
{
// do something...
}
}
If any of those vars have the value 0, false or null when set then this would not be the correct method. If you want the equivalent of the isset
function, you could use this:
function isset()
{
for (var i=0, l=arguments.length; i < l; i++)
{
if (typeof arguments[i] == "undefined" || typeof arguments[i] == "null")
return false;
}
return true;
}
Use it the same as you would the php function, e.g. isset(nation,service,slider);