Vigilant Psyche Posted July 29, 2008 Share Posted July 29, 2008 Say I have <textarea class='field' id='edit_t' rows=5 cols=30>foo</textarea> then I type in the text area, changing the value from "foo" to "bar", then I use this script: var new_text=document.getElementById('edit_t').innerHTML; alert(new_text); It still shows foo and not the new value of "bar". How can I fix this please guys? Quote Link to comment Share on other sites More sharing options...
obsidian Posted July 29, 2008 Share Posted July 29, 2008 Can you show us the context of your function calls? This works just fine for me: <script type="text/javascript"> function getValue(ele) { var e = document.getElementById(ele); alert('Current value: ' + e.value); } </script> <textarea id="myText" cols="40" rows="8" name="myText">foo</textarea><br /> <a href="#" onclick="getValue('myText'); return false;">Get Value</a> Tested in both FF and IE Quote Link to comment Share on other sites More sharing options...
Vigilant Psyche Posted July 29, 2008 Author Share Posted July 29, 2008 The script is run here when you click "edit". function open_edit(id) { var div=document.getElementById('edit_div'); var textarea=document.getElementById('edit_t'); var center=document.getElementById('edit_center_div'); textarea.innerHTML="Roorts"; div.style.display=''; center.innerHTML="<a href=javascript:edit("+id+")>edit</a>" } function edit(id) { object(); var div=document.getElementById('edit_div'); var new_text=document.getElementById('edit_t').innerHTML; alert(new_text); xmlHttp.onreadystatechange=function() { if (xmlHttp.readyState==4) { div.style.display=''; } } xmlHttp.open("GET",'info.php?body=edit&id='+id+'&new='+new_text,true); xmlHttp.send(null); } <div style="position:fixed;left:10px;top:10px;display:none;padding:5px;" class='sub_head' id='edit_div'><textarea class='field' id='edit_t' rows=5 cols=30></textarea><br/><div id='edit_center_div' style='text-align:center;'>edit</div></div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.