View Full Version : AJAX- Selection Item

07-19-2007, 09:48 AM

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>

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

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

07-19-2007, 07: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.

07-20-2007, 02:29 AM

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 ......
var xmlDoc=xmlHttp.responseXML.documentElement;

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

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

07-22-2007, 05: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!