dcsimg
how i could place data in a textbox
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Manu_A
Posted On:   Thursday, May 3, 2007 07:34 AM

Hi friends i am new to Ajax.I have a problem .I am trying to retrieve data from a database and the result to be shown in a text field.But when i tried as given in the following progm the entire html is shown in the output.Can i take a particular tagvalue (avoiding html tags)from the responseText and ahow it in the textbox... I am using jsp and mysql,IE. function createRequestObject() { var tmpXmlHttpObject; if (window.XMLHttpRequest) { . tmpXmlHttpObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP"); } return tmpXmlHttpObject;    More>>



Hi friends i am new to Ajax.I have a problem .I am trying to retrieve data from a database and the result to be shown in a text field.But when i tried as given in the following progm the entire html is shown in the output.Can i take a particular tagvalue (avoiding html tags)from the responseText and ahow it in the textbox...


I am using jsp and mysql,IE.












Have you heard these terms before?







Ceraunophobia More


about Ceraunophobia




Astraphobia More


about Astraphobia




Ophidiophobia More


about Ophidiophobia





























   <<Less

Re: how i could place data in a textbox

Posted By:   Anonymous  
Posted On:   Thursday, May 3, 2007 08:19 AM

Hi Manu,
Instead of http.responseText you can get the xml as http.responseXML to which you can parse using the DOM API and get the specific value in that xml you need to display in the text box.
suppose your xml is has some tag called "description" then you can write the below code .


var xml = http.responseXML;

var descriptions = xml.getElementsByTagName("description");


in the above statement descriptions is an array of the description tags so if you have only one you can directly use the 0 index to get that value like below.


document.getElementById('name').value = descriptions[0].firstChild.nodeValue;

to know more details you can look into the http://www.w3schools.com/dom/default.asp
Regards,
Krishna Rajendra A.
About | Sitemap | Contact