javascript - Updating input value [HTML/JS] -


i have got problem updating values in input filed [html]. possible update them on change? tried way (i used code found on site):

<input type="text" id='user' value='user' onchange="updateinput(this.value)"><br>  <script> var cc2 = document.getelementbyid("user").value;  function updateinput(ish){ document.getelementbyid("user").value = ish; } </script>  <a href="#" onclick="alert(cc2)">test</a> 

after pressing "test" link still receiving alert value: "user" no matter put in input.

please update updateinput following code

function updateinput(ish){ cc2=ish; } 

this assign value of input cc2 var. on each change in input make cc2 holds latest value.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -