Add class when inserting decimal number in input

Asked

Viewed 39 times

1

I would like to use decimal numbers, I will insert a decimal number into the input and I would like the class to pick when it is inserted, for example:

"min" => 0.00, "max" => 0.010

how can I do this?

<?php

$opcoes = array(
        "graphic-red" => array(
            "min" => 0,
            "max" => 200
        ),

        "graphic-blue" => array(
            "min" => 200,
            "max" => 500
        ),

        "graphic-green" => array(
            "min" => 500,
            "max" => 800
        ),

    );

    $val= "";
    $float  = floatval($val);
    echo $float; // 122.34343

    $rock_factor = get_post_meta(get_the_ID(), "rock_factor", true);
    $graphic =  getCssClassFromValue($rock_factor, $opcoes);

    function getCssClassFromValue($v, $op) {

        foreach ($op as $ch => $val) {

            if( $v > $val["min"]  &&
                $v < $val["max"] )                  
            {   
                return $ch;                 
            }
        }
        return "";
    }

?>
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.