jeudi 7 septembre 2017

how to make condition in input type min attribute

i have a question regarding in input type. Something, i want to make an if condition inside the min="" of input type.

Here is my code:

<input type="number" id="qty" name="qty" min="1" max="" step="1" value="1" readonly>

in my code, i have set min="1". What i want is something a condition like this inside the min.

min = " 
if($product_info[0]->quantity - $sessionQty == 0) {
    echo 0;
} else {
    echo 1;
}
"

the condition i put above is , when my $product_info[0]->quantity - $sessionQty would be equal to zero, i want the minimum value to be set 0 and when the condition is not zero then i will make the minimum value set to 1.

Aucun commentaire:

Enregistrer un commentaire