开发者

How do I set the value of a textbox array element using jquery?

开发者 https://www.devze.com 2023-03-28 22:12 出处:网络
how can i set a value to a textbox array element using jquery. i have an array of select and corrosponding textbox(array). when i select a diff value from the dropdown, it shud automatically populate

how can i set a value to a textbox array element using jquery. i have an array of select and corrosponding textbox(array). when i select a diff value from the dropdown, it shud automatically populate the textbox cor开发者_Python百科rosponding to it. also remember this select and textbox are created dynamically.

thanks in advance


Just do something like this:

var $text = $('#textbox'), $select = $('#selectMenu').change(function(){
  $text.val($select.val())
})


$('#myTextBox').val($('#mySelectBox').val());

You can add onChange to the select box to call the js function to do the above.


You should try something like :

$(function () {   
    function changed(select) {
         var newVal = select.value;
         ${"#yourTextBoxID"}.val(newVal);
     }
});

... and on your select

onchange="changed(this)"

0

精彩评论

暂无评论...
验证码 换一张
取 消