Jump to content

If Statement doubt


Danny1125

Recommended Posts

if(measure=="feat")

{

result=(wi*he);

         if(((wi*he))>0)

{

          result=result;

}

   //  alert(result);

}

 

 

  if(result=="0")

{

 result ="1";

}

 

 

This is my code. i want the result as : if the result is between 1-50, it should display 1, similarly 51-100 : 2, 101- 150 : 3, 151-200 : 4....

 

what code should i write in the result part? anyone help me out. its urgent.

Link to comment
Share on other sites

Your code doesn't make any sense, and this is clearly JavaScript, not PHP.

 

The display value can be obtained through simple division and the ceiling function:

<script>
    var resultTests = [1, 14, 50, 51, 60, 100, 101, 105, 150, 151, 153, 200];

    for (result of resultTests)
    {
        var display = Math.ceil(result / 50);

        console.log(result + " -> " + display);
    }
</script>
Edited by Jacques1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.