I want store the div's text in input field when select div content....... for example just create two div <div id="firstdiv" styel="width:200px; height:auto; border:1px solid #F00;">hi I am cool</div> <div id="seconddiv" styel="width:200px; height:auto; border:1px solid #F00;">hi I am working in NCR Zone</div> PHP: when I'm click on first div then firstdiv content "hi I am cool" are showing in inputfield <input type="text" name="test" value="hi I am cool" /> PHP: and if I'm click on second div then this input field store this content "hi I am working in NCR Zone" like this <input type="text" name="test" value="hi I am working in NCR Zone" /> PHP: and replace first content from input field. Plz help ..............
You want something like this? <html> <head> <title>dive</title> <script> function fnOC(od) { var oi; oi=document.getElementById('idInput'); oi.value=od.innerHTML; } </script> </head> <body> <div id="firstdiv" styel="width:200px; height:auto; border:1px solid #F00;" onClick='javascript:fnOC(this);'>hi I am cool</div> <div id="seconddiv" styel="width:200px; height:auto; border:1px solid #F00;" onClick='javascript:fnOC(this);'>hi I am working in NCR Zone</div> <input type="text" id='idInput' name="test"/> </body> </html>