CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jul 2009

    Dynamic Drop down lists

    Hi I'm completely new to AJAX and am trying to create a dropdown list where each field populates depending on the value entered in the previous one.

    I am trying to test it initially with just one value. My PHP works fine on Submit but AJAX won't work for me.

    The code is in an external .js file which I call along with the PHP and parameters from the main html.

    I'm a complete novece so any help would be great!


    I used a fairly simple tutorial and based my code on that. Here it is:

    <form action="process.php" method="post">
    <td align="right">Language of interest:</td>
    <select name="language" onChange="getCity('findcity.php?language='+this.value)">
    <option value="none selected"> --- select --- </option>
    <option value="French">French</option>
    <option value="German">German</option>
    <option value="Italian">Italian</option>
    <option value="Spanish">Spanish</option>
    <option value="Russian">Russian</option>
    <td align="right">Course Type</td>
    <select name="course" >
    <option value="none selected"> --- select --- </option>
    <option value="Junior">Junior</option>
    <option value="Other">Other</option>
    <td align="right">School</td>
    <select name="school">
    <div id="citydiv">
     <option>Select School</option>
    function getCity(strURL)
    	var xmlhttp;
    if (window.XMLHttpRequest)
      // code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
    else if (window.ActiveXObject)
      // code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      alert("Your browser does not support XMLHTTP!");
          req.onreadystatechange = function()
          if (req.readyState == 4) { //data is retrieved from server
           if (req.status == 200) { // which represents ok status                    
             alert("There was a problem while using XMLHTTP:\n");
        req.open("get", strURL, true); //open url using get method
    Last edited by PeejAvery; July 14th, 2009 at 06:34 AM. Reason: Added code tags.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.