Re: Setting javascript variable to false?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you:
That worked for me.
JK
> On Mar 12, 2020, at 1:31 PM, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote:
> 
> This should work:
> 
> var dual = <?php echo $dual ? 'true' : 'false'; ?>
> 
> On Thu, Mar 12, 2020 at 4:22 PM Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:
> Hello;
> 
> I have javascript global variable in a page that is supposed to be
> initialized by php:
> 
> // $dual is boolean true/false
> 
> var dual = <?php print $dual ?>
> 
> But what happens when the page loads is:
> 
> var dual = ; // true/false is not written to the page. javascript syntax checker complains.
> 
> How would I output a string version of true/false that
> javascript will see as a boolean value?
> 
> I had been sending $dual as 'true'/'false'
> 
> but then when checking dual:
> if(dual)
>   {
>    // if dual is the string 'false', the test passes.
> }
> 
> Thank you for time and attention
> JK




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux