boolean value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SSG001
    New Member
    • Oct 2007
    • 110

    boolean value

    [PHP]<? $init=false; ?>
    <script language="JavaS cript">var init=false;
    if(!init){init= confirm('Are you sure You want to confirm the test results for '+'<?=$mm_cde."--".$mbatchno?>') ;}
    alert('ss'+init );
    if(!init){
    alert('fffff'+i nit);<? $init=false;?>} ;
    else{
    alert('ttt'+ini t);<? $init=true;?>;
    }
    alert('<?=$init ?>');
    </script>
    <? if((int)$init== 1){
    ?><script>alert ('yes');</script><?
    }
    else{
    ?><script>alert ('yes');</script><?

    }
    <?[/PHP]


    this always alerts yes ieven if i press cancel

    wot's wrong with the code

    thanks in advance
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    PHP and JavaScript don't get executed together on a same processor. PHP would not act according to the if else you have applied in JavaScript. Do view source of your page.
    Sort out your algorithm again.

    Comment

    • satas
      New Member
      • Nov 2007
      • 82

      #3
      [QUOTE=SSG001][PHP]if(!init){
      alert('fffff'+i nit);<? $init=false;?>} ;
      else{
      alert('ttt'+ini t);<? $init=true;?>;
      }[/PHP]

      Wrong. Learn difference between where javaScript and PHP code are running.

      And fix your last if/else clause, there are two 'yes' alerts.

      Comment

      Working...