I'm trying to update an input value using jquery and I can't get it to do anything. I've tried .val(), .attr, .html, .text.

$('#acctnum').click(function(){
        var index = this.selectedIndex;
        var bal1 = $('#bal1').val();
        var bal2 = $('#bal2').val();
        var bal3 = $('#bal3').val();
        var bal4 = $('#bal4').val();


        if (index == 0){
            $('#poamnt').val(bal1);
            alert (bal1);
        } else if (index == 1){
            $('#poamnt').val(bal2);
            alert (bal2);
        } else if (index == 2){
            $('#poamnt').val(bal3);
            alert (bal3);
        } else if (index == 3){
            $('#poamnt').val(bal4);
            alert (bal4);
        }

    });

Here is the html

 <li><label for="poamt">PO Amount</label> <input readonly type="text" id="poamt" name="poamt"/></li>

I can console.log and get the correct index number and val from my vars.

shouldn't it be

`$('#poamt').val(bal1);`

instead of

 ` $('#poamnt').val(bal1);`
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.