Syed Rasheed Syed Rasheed - 8 months ago 22
Javascript Question

How to give value of textbox to ngModel textbox using javascript

This is my first html textbox with javascript code

<input type="text" onchange="getTheValue(this)" id="12345" />

and this is my second html tag

<input type="hidden" id="12345_hiddenField" ng-model="hiddenField"/>

And on
event i am calling this javascript function

function getTheValue(data) {
document.getElementById("12345_hiddenField").value = data.value;

i want first textbox value to be assigned to second textbox
value with pure javascript no angualrjs methods in that, becoz that
function is written in seperate pure javascript file,is their anyway to do this?


I would do it like this.

 document.getElementById("12345").addEventListener('change',function() {
 document.getElementById("12345_hiddenField").value = document.getElementById("12345").value;

See fiddle