jeudi 30 août 2018

multiple if statement with javascript in html input

I want to execute specific javascript if $_post['value'] larger than 100 and another javascript if $_post['value'] smaller than 100

<script language="JavaScript">
    if (document.getElementById("user_amount") > 100) {
        function euroConverter() {
            document.amount.value =
            document.user_amount.value - (document.user_amount.value * 0.08)
        }
    }

    if (document.getElementById("user_amount") < 100) {
        function euroConverter() {
            document.amount.value =
            document.user_amount.value - (document.user_amount.value * 0.1)
        }
    }
</script>

and html

<div class="form-group input-group">
    <input type="number" id="user_amount" class="form-control" name="user_amount" onChange="euroConverter()">
    <span class="input-group-addon"><i class="glyphicon glyphicon-usd"></i></span>
</div>
<div class="form-group input-group">
    <input type="number" class="form-control" name="amount" onChange="dollarConverter()">
    <span class="input-group-addon"><i class="glyphicon glyphicon-usd"></i></span>
</div>

Thanks

Aucun commentaire:

Enregistrer un commentaire