Change value of input onchange?

后端 未结 2 605
春和景丽
春和景丽 2020-12-05 04:31

I am trying to create a simple JavaScript function. When someone inserts a number in an input field, the value of another field should change to that value. Her

相关标签:
2条回答
  • 2020-12-05 05:07

    for jQuery we can use below:

    by input name:

    $('input[name="textboxname"]').val('some value');
    

    by input class:

    $('input[type=text].textboxclass').val('some value');
    

    by input id:

    $('#textboxid').val('some value');
    
    0 讨论(0)
  • 2020-12-05 05:20

    You can't access your fieldname as a global variable. Use document.getElementById:

    function updateInput(ish){
        document.getElementById("fieldname").value = ish;
    }
    

    and

    onchange="updateInput(this.value)"
    
    0 讨论(0)
提交回复
热议问题