...

View Full Version : AJAX- Selection Item



charon
07-19-2007, 08:48 AM
Hi,

How do I achieve this in AJAX?

String history = value_from_database

<select name="history">
<option value="N" <%if(history.equals("N")){%>selected<%}%>>N</option>
<option value="Y" <%if(history.equals("Y")){%>selected<%}%>>Y</option>
</select>

I really have no idea how to get my data from my xml file and put it into the selection list above.

Pls advise.......................

glenngv
07-19-2007, 06:36 PM
Your code looks like JSP, so why do you need AJAX? You are on the server-side so you don't need AJAX.

charon
07-20-2007, 01:29 AM
Hi,

Ya, all the while I'm using server script to achieve this, now just know the power of AJAX, so would like to apply AJAX in this.

Normally when we get the data from database, if matches the value in the slection option, then will be automatically selected. In AJAX, I really have no idea how to achieve this....

For the form elements such as text, normally we can get the value from xml and display in the text field by using the xmlHttpRequest as below:

Java function here ......
.......
xmlHttp=GetXmlHttpObject();
var xmlDoc=xmlHttp.responseXML.documentElement;
document.getElementById("myTextfield").innerHTML=
xmlDoc.getElementsByTagName("compname")[0].childNodes[0].nodeValue;

But for the list down menu, really have no idea.....

Do hope can get advise.......

charon
07-22-2007, 04:10 PM
Well, just forget about this....guess I'm having typo error...
I did try to use:

document.form[history].value ="Y", the correct one is :

document.forms[0]['history'].value ="Y";

Thanks you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum