Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX- Selection Item

    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.......................

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Your code looks like JSP, so why do you need AJAX? You are on the server-side so you don't need AJAX.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.......
    Last edited by charon; 07-20-2007 at 02:39 AM. Reason: explain more

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    317
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •