I want to create a link where if the user presses the Edit link, the text will turn into a text box with the information still in what the user inputted? I have the following code: ( when i press the edit button the 'Text here' should turn into a textbox, but it doesn't could someone help notify where my code has gone wrong :) help would be appreciated.
<html> <head> <title>Span to Text Box - Demo</title> <style type="text/css"> .replace { display:none; } </style> <script type="text/javascript"> function exchange(id){ var ie=document.all&&!window.opera? document.all : 0 var frmObj=ie? ie[id] : document.getElementById(id) var toObj=ie? ie[id+'b'] : document.getElementById(id+'b') toObj.style.width=frmObj.offsetWidth+7+'px' frmObj.style.display='none'; toObj.style.display='inline'; toObj.value=frmObj.innerHTML } </script> </head> <body> <p class="edit" onclick="exchange(item)">Edit</p><Input id="item" class="replace" type="text" value=""> <span id="item" >Text here</span> </body> </html>