I'm learning HTML/CSS/JS/Jquery. I'm working on a page has multiple text input items. Somehow I want to automatically copy content of 1 input (main_item) and paste on other inputs.
I found this topic almost solve my problem: How can I select an element by name with jQuery?
But as my case, the fields I need to be auto-filled is created as an objects array and accessed by it's name (quote_item[#][item]) and I've tried this but no use:
$("#main_item").keyup(function(){
update();
});
function update() {
$("input[name*=quote_item").val($('#main_item').val());
}
<p>Main item: <input type="text" id="main_item" name="main_item" value=""></p>
<p>
<input type="text" name="item[0][item-code]" value="">
<input type="text" name="item[1][item-code]" value="">
</p>
Please help!