-1

i have this code:

Amount<input type='text' name='amount' size='10'  >
  <br>      
Free<input type='text' name='fees' size='10' > 
 <br> 
 ------------
 <br>
<input type='radio' name='amount_type' value='Receive'checked> Receive<br>
<input type='radio' name='amount_type' value='Send'> Send<br>
-------------
 <br>
        
<input type='radio' name='curr' value='LBP'checked> LBP<br>
<input type='radio' name='curr' value='USD'> USD<br>

what i want to do is

  • if amount more than 5000 , check radio button curr : value LBP else check usd

  • if fees are inserted , in radio button amount_type : check Receive else check send.

can you assist please

Hussein
  • 97
  • 12

1 Answers1

1

Use this code.

Amount<input type='text' name='amount' size='10' id='amount'  >
  <br>      
Free<input type='text' name='fees' size='10' id='fees' > 
 <br> 
 ------------
 <br>
<input type='radio' id='receive' name='amount_type' value='Receive'checked> Receive<br>
<input type='radio' id='send' name='amount_type' value='Send'> Send<br>
-------------
 <br>

<input type='radio' id='lbp' name='curr' value='LBP'checked> LBP<br>
<input type='radio' id='usd' name='curr' value='USD'> USD<br>

jquery

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
    $("#usd").prop("checked", true);
    $("#send").prop("checked", true);
    $("#amount").on("input", function(){
        // Print entered value in a div box
        if($("#amount").val() > 5000){
            $("#lbp").prop("checked", true);
        }else{
            $("#usd").prop("checked", true);
        }
    });
    $("#fees").on("input", function(){
        // Print entered value in a div box
        if($("#fees").val() > 0){
            $("#receive").prop("checked", true);
        }else{
            $("#send").prop("checked", true);
        }
    });
});
</script> 

check out online demo : DEMO

mufazmi
  • 1,103
  • 4
  • 18
  • 37
  • perfect , thanxx – Hussein Dec 08 '19 at 12:06
  • it's my pleasure ♥ – mufazmi Dec 08 '19 at 12:09
  • 1
    SO is not a code writing service. You are doing a disservice by answering such questions. Instead, vote to close the question. [What topics can be asked here?](https://stackoverflow.com/help/on-topic) and [How To Answer](https://stackoverflow.com/help/how-to-answer) – Rob Dec 09 '19 at 02:32