By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,384 Members | 1,829 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,384 IT Pros & Developers. It's quick & easy.

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

P: 45
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.

Aug 2 '08 #1
Share this Question
Share on Google+
5 Replies

Expert Mod 15k+
P: 16,027
The only difference is instead of innerHTML (which is what I assume you used for the div), use value to set the text box.
Aug 2 '08 #2

P: 45
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.
Expand|Select|Wrap|Line Numbers
  2. This is my ajax code:
  3. if (ObjectName=="PARTY_CODE")
  4.          {
  5.  document.getElementById("txtHint2").innerHTML=xmlHttp.responseText 
  6.          }
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
Aug 3 '08 #3

Expert Mod 15k+
P: 16,027
If your input box is marked up like this:
[html]<input type="text" id="test" name="test">[/html]then to change/set its value:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("test").value = "whatever value you want to set here...";
Aug 3 '08 #4

P: 45
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
Aug 4 '08 #5

Expert Mod 15k+
P: 16,027
You're welcome. That's what we're here for ;)
Aug 4 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.