Moonsoft Software Solutions

if else fuction

Started 5 Feb 2015 · 1 reply

  1. todanai
    Dear all, I have the fuction. If epan>2 then I want to see the results in the result layout else I want to have an error message asking user to insert new values. Unfortunately I don't know what to put after "else"

    This is the half of the code:

    $aferesi=$mashali-$omos;
    $afer=$aferesi/2;
    $epal=sires/afer;
    if ($epal > "2") {
    $p=$sires-$aferesi;
    $p2=$p/2;
    $x=$afer-$p2;
    }
    else {
    I want to see a message error or a pop up error!!!??
    }
  2. Moonsoft support
    Hi,
    if you were printing a single result, like $result, you could use that approach to set $result with the if/else structure:

    if($epal>2){
    //calculations
    $result=376;
    }

    else{

    $result="Error:Message";
    }


    but looking at your code, seems you are calculating several results, so we'd use this solution instead:


    At your exit layout, create the two sections (real results, and error message). Enclose each one inside a div and set a different style for each one:

    //real results

    ...div style="display:##displayreal##"


    //here your result section..close div


    //error section

    ..div style="display:##displayerror##"

    //here your error section...close div



    and now you can set at the code the display of each section according to your condition:


    //calculations

    if($epal>2){

    $displayreal="block";
    $displayerror="none";
    }

    else{
    $displayreal="none";
    $displayerror="block";

    }


    Please let us know if you need further help with this.


    Thanks, regards

Still stuck?

Customers with an active license can open a support ticket.

Log in to open a ticket