Retrieving already assigned text box value dynamically in javascript
<p>I have a form in PHP which looks like this:</p>

<pre><code>&lt;?php
   $txtVal1 = "value1";
?&gt;
&lt;script type="text/javascript"&gt;
 function post_data(){
   alert(document.getElementById("text1").value);
 }
&lt;/script&gt;
&lt;form method="post" action=""&gt;
&lt;input type="text" value="&lt;?php echo $txtVal1;?&gt;" id="text1"/&gt;
&lt;input type="button" value="Post" onclick="post_data()"/&gt;
&lt;/form&gt;
</code></pre>

<p>My question is whenever I click "Post" button I get an alert message as "value1". This is fine. But now if I change the text box value to something else from the UI I still get the old value. Is there any solution to get the changed value?</p>
