Add class when entering decimal number in input

1

I would like to use decimal numbers, I will insert a decimal number in the input and would like the class to pick up when it was 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 "";
    }

?>
    
asked by anonymous 16.04.2018 / 17:58

0 answers