how to put div id content inside a input box in html page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boss1
    New Member
    • Sep 2007
    • 45

    how to put div id content inside a input box in html page

    hello everyone,

    i need your help.
    i m using ajax to retrieve value from database and showing it within html form insise div tag .its working well.But now i need to show div id content(field value from database) inside a input box.i m using onchange event.

    how to do it ?
    can any one please help me out.

    Thanks
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The only difference is instead of innerHTML (which is what I assume you used for the div), use value to set the text box.

    Comment

    • boss1
      New Member
      • Sep 2007
      • 45

      #3
      The way you have suggested is not working for me. i willbe happy if you give me an example. here i have given some code of me.Try to give a soluation from it.
      [code=javascript]

      This is my ajax code:
      if (ObjectName=="P ARTY_CODE")
      {
      document.getEle mentById("txtHi nt2").innerHTML =xmlHttp.respon seText
      }[/code]

      This is where i want to show value:
      [HTML] <td width ="10%" align =left><td><div id="txtHint2"> </div></td>[/HTML]

      txthint2 Contain the party name against party code.

      now i want to show value of" txtHint2" inside a input box or text box ,sothat i can send it to database.
      so what do do with it? please help me
      Last edited by acoder; Aug 3 '08, 09:44 AM. Reason: Added [code] tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        If your input box is marked up like this:
        [html]<input type="text" id="test" name="test">[/html]then to change/set its value:
        [code=javascript]document.getEle mentById("test" ).value = "whatever value you want to set here...";[/code]

        Comment

        • boss1
          New Member
          • Sep 2007
          • 45

          #5
          Hi acoder,

          Thank you so much. Your given idea is working properly.

          i have spent a lot days for it.But i could'nt now it's working.

          Tank u so much again

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You're welcome. That's what we're here for ;)

            Comment

            Working...