Vahid Alvandi Vahid Alvandi - 24 days ago 6
CSS Question

how i can set value to input text box programmatically in jquery

i set address image file to a text box with click a button this work okay.

i need a listener to get value from text box and show alert. i don't need use change event i don't use keyboard value insert by a function

$("#add").click(function(){
$("input").val('http://localhost/afa/uploads/source/error-img.png');
});


after insert address file i show a alert with content value input

var val = $("#fieldID4").val();
files2.push({src:val});
updateList2(files2.length-1);


function updateList2(n) {
var e = thumb.clone();
e.find('img').attr('src',files2[n].src);
e.find('button').click(removeFromList).data('n',n);
gallery.append(e);

function removeFromList() {
files2[$(this).data('n')] = null;
$(this).parent().remove();
}
}

Answer

i solve this problem with use onchange event

[http://www.w3schools.com/jsref/event_onchange.asp][1]

   <input  id="fieldID4" type="text" onchange="myFunction()" value="" >

function myFunction() {
    var val = document.getElementById("fieldID4").value;

files2.push({src:val});
updateList2(files2.length-1);


}