PHP expert |
|
Ik ben me nu op Ajax aan het storten maar ik heb een probleem..
Ik heb de volgende html code:
<tr>
<td class="left">Continent:</td>
<td class="right">
<select name="getcountry" onChange="getCountry()">
<option value="">Choose a continent</option>
<?php
$select = $db->Query("SELECT id, continent_en
FROM continents
ORDER BY id");
while($ass = $db->Fetch_Assoc($select))
{
?>
<option value="<?= $ass['id'] ?>"><?= $ass['continent_en'] ?></option>
<?php
}
?>
</select></td>
</tr>
<tr>
<td class="left">Countries</td>
<td class="right">
<div id="countries"><i>Choose a continent to continue</i></div>
</td>
</tr>
<tr> <td class="left">Continent:</td> <td class="right"> <select name="getcountry" onChange="getCountry()"> <option value="">Choose a continent</option> <?php $select = $db->Query("SELECT id, continent_en FROM continents ORDER BY id"); while($ass = $db->Fetch_Assoc($select)) { ?> <option value="<?= $ass['id'] ?>"><?= $ass['continent_en'] ?></option> <?php } ?> </select></td> </tr> <tr> <td class="left">Countries</td> <td class="right"> <div id="countries"><i>Choose a continent to continue</i></div> </td> </tr>
Maar ik krijg nu de volgende error van FireBug terug:
getCountry is not a function
Maar die functie bestaat wel hier:
function createRequestObject()
{
var request_;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
{
request_ = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
request_ = new XMLHttpRequest();
}
return request_;
}
var http = createRequestObject();
function getCountry()
{
http.open('get', 'data.php?act=country&id='
+ document.form_select.getcountry.selectedIndex);
http.onreadystatechange = handleInfo;
http.send(null);
}
function handleInfo()
{
if(http.readyState == 1)
{
document.getElementById('countries').innerHTML = 'Loading...';
}
if(http.readyState == 4)
{
var response = http.responseText;
document.getElementById('countries').innerHTML = response;
}
}
function createRequestObject() { var request_; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer") { request_ = new ActiveXObject("Microsoft.XMLHTTP"); } else { request_ = new XMLHttpRequest(); } return request_; } var http = createRequestObject(); function getCountry() { http.open('get', 'data.php?act=country&id=' + document.form_select.getcountry.selectedIndex); http.onreadystatechange = handleInfo; http.send(null); } function handleInfo() { if(http.readyState == 1) { document.getElementById('countries').innerHTML = 'Loading...'; } if(http.readyState == 4) { var response = http.responseText; document.getElementById('countries').innerHTML = response; } }
De file word wel goed geinclude, maar hij zeurt dus over een functie die niet schijnt te bestaan. Wat vergeet ik
edit:
Hij upload de hele tijd het verkeerde bestand met dreamweaver, dus via smartftp lukt het wel..
Hij deed het dus wel
|