Div Text store in input field

Discussion in 'PHP' started by dineshsingh1984, Feb 26, 2011.

  1. #1
    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 ..............
     
    dineshsingh1984, Feb 26, 2011 IP
  2. skaa7

    skaa7 Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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>
     
    skaa7, Feb 28, 2011 IP
  3. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Thanks skaa7, Definetally I want like this.
    thanks once again.....
     
    dineshsingh1984, Feb 28, 2011 IP