Jump to content


  • Content count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About kwstephenchan

  • Rank
    Regular Member

Profile Information

  • Gender
    Not Telling
  1. Hi, I am sorry about the crumpsy title as I do not know how to put it. My problem is: I have a dependable dropdown list that help produce a list of states. But I want to select a particular state and change the information of that state, so I put an onChange event so that supposedly details of that state will be produced for modification. But the script is not answering the onChange event (have put an alert statement in the function and it is not showing it) I am totally new to Ajax and using this to learn, would someone please help point out what's wrong with it. Thanks in advance. The html are: <tr valign="baseline"> <td width="30%" align="right" class="lbtxt"><?php echo "Country : "; ?></td> <td><select name="m_country" onChange="getState(this.value)"> <option value=""><?php echo "Select Country"; ?></option> <?php mysql_select_db($database_conEstate, $conEstate); $cRS = mysql_query("SELECT * FROM country order by ".$lang."countryname asc") or die(mysql_error()); while ($crow = mysql_fetch_assoc($cRS)) { echo "<option value="; echo $crow['countryid']; echo ">"; echo $crow[$lang."countryname"]; echo "</option>"; } ?> </select> </td> </tr> <tr valign="baseline"> <td width="30%" align="right" class="lbtxt"><?php echo "State :"; ?></td> <td><div id="statediv"><select name="m_state" onChange="lookupstate('<?php echo $countryid; ?>','<?php echo $stateid;?>','<?php echo $showen; ?>','<?php echo $showbg; ?>','<?php echo $showgb;?>' );"> > <option><?php echo "Select Country First"; ?></option> </select></div> </td> </tr> The javascripts are: var urlstate = "lookupstate.php?param="; // The server-side script //alert{"here before lookupstate"); function lookupstate(countryid,stateid,showen,showbg,showgb) { alert("in lookupstate"); var http; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari http = new XMLHttpRequest(); } else { // code for IE6, IE5 http = new ActiveXObject("Microsoft.XMLHTTP"); } var id1=countryid; var id2=stateid; var showen=showen; var showbg=showbg; var showgb=showgb; // var showid=showid; var cid1 = document.getElementById(id1).value+","+document.getElementById(id2).value; alert("cid1="+cid1); http.open("POST", urlcountry + escape(cid), true); http.onreadystatechange = function() { try { if (http.readyState == 4 ) { // results = http.responseText; // document.getElementById(showen).value = results; results = http.responseText.split(","); document.getElementById(showen).value = results[0]; document.getElementById(showbg).value = results[1]; document.getElementById(showgb).value = results[2]; if (cid=="00") { document.getElementById(showen).value = ""; document.getElementById(showbg).value = ""; document.getElementById(showgb).value = ""; } else { // document.getElementById(showid).disabled=true; } } } catch(e){} } http.send(null); // http.onreadystatechange = handleHttpResponse; // http.send(null); }
  2. kwstephenchan

    ajax not getting the updated data

    Just solved. I should be using POST instead of GET in my ajax calls.
  3. kwstephenchan

    ajax not getting the updated data

    Hi, I have an ajax call to display the country name for update. After I change the data and press the updated button, (the data is updated to the database). But if I select the same country id (without leaving the page), it gives me the old data. Only if I leave the browser completely and call this ajax again, it then will give me the updated data. Don't know why can someone please advise what is causing the problem. The sequence of events are: 1. call out the country 2. update the country name 3. call out the country (here it is not showing the updated country name) But if I leave the browser completely, it will show me the updated country name Thanks.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.