473,546 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

populating a drop down with Ajax? IE problems.

27 New Member
I have a page with google maps up and running. When a user clicks on a location from the map I would like to populate a drop down with data from the database related to that location. I have it up and working wonderful. Well that was what I thought until I tried it is IE. All that I get is an empty drop down. I know the problem is related to filling the element with the xmlHttp.respons eText, but no matter how many solution I have tried as suggested by google I still have no luck.

main php page
[php]
<div style="width:33 0px; height:600px; float:left;">
<div>
<form id="pestForm" action="fruit.p hp?option=repor t" method="post">
<fieldset style="width:28 0px;">
<legend>Pest</legend>
<div id="error"><?ph p echo $_SESSION[error]; ?></div>
<p>
<label for="pest">Pest </label>
<select style="width:17 0px;" id="pest" name="pest" >
<option value="">Select Pest</option>
</select>
</p>
<p>
<label for="biodate">B iofix Date</label>
<input type="text" id="biodate" name="biodate" value="<? echo '01/01/' . date('Y'); ?>" size="10" maxlength="10" />
<input type="button" style="border-width: 0px; height: 17px; width: 19px; background-image: url('/img/calendar1.gif') ;
</p>
<p>
<label for="enddate">E nd Date</label>
<input type="text" id="enddate" name="enddate" value="<? echo date("m/d/Y"); ?>" size="10" maxlength="10" />
<input type="button" style="border-width: 0px; height: 17px; width: 19px; background-image: url('/img/calendar1.gif') ;
</p>
<div class="buttonbo x">
<input type="submit" name="pSubmit" value="Submit" onclick="if (pestCheck() == false) return false;" />
<input type="reset" />
<input type="button" onclick="locati on.href='index. php'" value="Back" />
</div>
</fieldset>
</form>
</div>
</div>
[/php]


javascript used when a location is clicked
Expand|Select|Wrap|Line Numbers
  1. // This function is called each time a station marker is added
  2. // it formats the station's tooltip and adds event listeners for click, hover, etc.
  3. function formatMarker(station) {
  4.    var num = station.stn_num;
  5.    var name = station.stn_name;
  6.    var div_width = (7.9 * name.length) + 48;
  7.    if(div_width < 110) div_width = 110;
  8.    station.tooltip = "<div id=\"tooltip\" style=\"width:" + div_width + "px\">Num:"+num+'<br/>Name: ' + name + '</div>';
  9.  
  10.    // Add listener for marker click events
  11.    // if a station icon is clicked, its corresponding id is displayed
  12.    GEvent.addListener(station, "click", function() {
  13.          setPest();
  14.    });
  15.  
  16.    // Add listener for marker hover events
  17.    // if the user hovers over a station icon, information about the station is displayed
  18.    GEvent.addListener(station,"mouseover", function() {
  19.          showTooltip(station);
  20.    });
  21.    GEvent.addListener(station,"mouseout", function() {
  22.          globaltooltip.style.visibility="hidden";
  23.    });
  24.    return station;
  25. }
  26.  
  27. function setPest() {
  28.    var xmlHttp = false;
  29.    try {
  30.       xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
  31.    } catch (e) {
  32.       try {
  33.          xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  34.       } catch (e) {
  35.          xmlHttp = false;
  36.       }
  37.    }
  38.  
  39.    if (!xmlHttp && typeof XMLHttpRequest!='undefined') {
  40.       try {
  41.          xmlHttp = new XMLHttpRequest();
  42.       } catch (e) {
  43.          xmlHttp = false;
  44.       }
  45.    }
  46.  
  47.    if (!xmlHttp && windos.createRequest) {
  48.       try {
  49.          xmlHttp = window.createRequest();
  50.       } catch (e) {
  51.          xmlHttp = false;
  52.       }
  53.    }
  54.  
  55.    //xmlHttp.overrideMimeType('text/xml');
  56.  
  57.    var url = "includes/ajax.php";
  58.  
  59.    xmlHttp.onreadystatechange=function() {
  60.       if(xmlHttp.readyState==4) {
  61.          //alert(xmlHttp.resonseText);
  62.             var spanElement = document.getElementById('pest');
  63.             spanElement.innerHTML = '';
  64.             try {
  65.                spanElement.innerHTML = xmlHttp.responseText;
  66.             } catch (e) {
  67.                var wrappingElement = document.createElement('div');
  68.                wrappingElement.innerHTML = xmlHttp.responseText;
  69.                spanElement.appendChild(wrappingElement);
  70.             }
  71.       }
  72.    }
  73.  
  74.    xmlHttp.open("POST",url,true);
  75.    xmlHttp.send(null);
  76. }
  77.  
php code that queries the database includes/ajax.php
[php]
<?php
$query = "SELECT pest_id, name FROM pests;";
$result = pg_query($query );

header("Content-type: text/xml");
$pest .= "<option value=''>Select Pest</option>\n";
while($info = pg_fetch_row($r esult)) {
$name = htmlentities(tr im($info[1]));
$pest .= "<option value='$info[0]' >$name</option>\n";
}

echo $pest;
exit;
?>

[/php]

You help is welcome.

Here is the link if you want to try to see my problem. The error is only seen in IE
http://beta.climate.usurf.usu.edu/fruit.php
May 19 '08 #1
1 1853
acoder
16,027 Recognized Expert Moderator MVP
The link isn't working, so can you show how you call formatMarker()?
May 20 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2464
by: msnews.microsoft.com | last post by:
I'd like to hear your thoughts on best methods for populating drop down list controls. I have states and countries drop down lists that don't change often, so naturally I "hard code" them in the aspx page. But the problem is these tend to really slow the development -- it takes up to 15 seconds for the page to come up in VS.NET design...
4
8056
by: Pete Lux | last post by:
I have a drop down that populates on page load. The drop down brings in customer numbers from my local MSDE database. It does this fine, but I click a button that finds quotes for those customers and the next time I go to drop down the list, all the customer numbers are doubled (1015,1016,1017,1015,1016,1017..) How do I get that to stop? Do...
3
6877
by: Yi Chen | last post by:
We have a drop down list on a PHP page, with several product names, and when people click one item, we will refresh the same page with the product name as parameter, and in turn we want to include a HTML file into the content area of the same page. I know it is recommended to put everything into database, but we want the web site to be very...
1
3584
by: Jeff Gardner | last post by:
Greetings: I have a table with 3 pieces of data that I would like to use to dynamically populate 3 drop downs using javascript. The fields are state, orgname, office. If it's not already obvious, I'd like orgname drop down to change when a state is selected and I would like office drop down to change when an orgname is selected. I can do...
1
1836
by: Boris Twila | last post by:
I just want to have 1 drop down list fill the other drop down list without a round trip. Is there some really simple ajax thing i can copy and use, or is it a big deal do i habe to install an ajax server or something
6
3072
by: Rob Meade | last post by:
Hi all, Looking for a bit of help if possible. For about 2 weeks now I've been investigating the best way to populate related drop down menus, and have their values pre-populated again if the user clicks back with their selected options still selected - and I'm getting to the point where I might just popup a big window, perhaps with some...
1
1347
by: JackInDaBox | last post by:
Hello, I am new to this and have run into a small problem. I am using the Ajax toolkit with VS 2005 to fill some drop downs through a web service and it works great. All of the cascading drop downs work correctly. The only problem I have is I need to copy the drop downs value from each cascading drop down into a hidden drop down. I have...
11
4608
by: tokcy | last post by:
Hi everyone, I am new in php and ajax, i am facing the prob while i click on element of first drop down then in second dropdown all element showl come from database. I mean i have three dropdown 1. category which comes from database 2. brand which comes from databse according to content of first dropdown . and 3. price which is static. when i...
14
4314
by: Philth | last post by:
Hi there, I've essentially got a form with several drop down, each populated by columns in various tables. The populating bit works fine - the column rows appear as they should in the menu. Ideally the user needs to make their selections, and enter the form into a new database table. The problem is, when the selection is entered into...
0
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7698
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6030
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.