Ik heb online de code gevonden om listbox 2 te vullen aan de hand van lisbox 1 en dan listbox 3 aan de hand van listbox 2
2 vullen na keuze van 1 werkt
maar 3 vullen na keuze van 2 werkt niet (de javascript wordt zelfs niet aangeroepen)
mijn vraag:waarom wordt getSubregio niet uitgevoerd?
demo op:
http://www.tornooi.net/joomla160/jumifiles/droptest.php
de js:
[JS]<script language="javascript" type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getRegio(countryId) {
var strURL="http://www.tornooi.net/joomla160/jumifiles/findregio2.php?country="+countryId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('regiodiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
function getSubregio(countryId,stateId) {
alert("hier");
var strURL="http://www.tornooi.net/joomla160/jumifiles/findsubregio2.php?country="+countryId+"&state="+stateId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('subregiodiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>[/JS]
de html/php code:
de eerste hulpfile:findregio2.php (werkt als je hem appart oproept.)
tweede php hulpfile findsubregio2.php die niet uitgevoerd wordt doordat hat js commando niet aangeroepen wordt?
waarom wordt getSubregio niet uitgevoerd?
2 vullen na keuze van 1 werkt
maar 3 vullen na keuze van 2 werkt niet (de javascript wordt zelfs niet aangeroepen)
mijn vraag:waarom wordt getSubregio niet uitgevoerd?
demo op:
http://www.tornooi.net/joomla160/jumifiles/droptest.php
de js:
[JS]<script language="javascript" type="text/javascript">
function getXMLHTTP() { //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function getRegio(countryId) {
var strURL="http://www.tornooi.net/joomla160/jumifiles/findregio2.php?country="+countryId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('regiodiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
function getSubregio(countryId,stateId) {
alert("hier");
var strURL="http://www.tornooi.net/joomla160/jumifiles/findsubregio2.php?country="+countryId+"&state="+stateId;
var req = getXMLHTTP();
if (req) {
req.onreadystatechange = function() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
document.getElementById('subregiodiv').innerHTML=req.responseText;
} else {
alert("There was a problem while using XMLHTTP:\n" + req.statusText);
}
}
}
req.open("GET", strURL, true);
req.send(null);
}
}
</script>[/JS]
de html/php code:
PHP:
<table>
<tr><td class="filtertekst">Land: </td>
<td class="filteroptie">
<SELECT id="country_code" name="country_code" onchange="getRegio(this.value)">
<OPTION value="0" <?if ($zoek[0]=="0"){print "SELECTED";}?>>Kies een land</OPTION>
<OPTION value="BE" <?if ($zoek[0]=="BE"){print "SELECTED";}?>>België </OPTION>
<OPTION value="DK" <?if ($zoek[0]=="DK"){print "SELECTED";}?>>Denemarken</OPTION>
<OPTION value="DE" <?if ($zoek[0]=="DE"){print "SELECTED";}?>>Duitsland</OPTION>
<OPTION value="FR" <?if ($zoek[0]=="FR"){print "SELECTED";}?>>Frankrijk</OPTION>
<OPTION value="IE" <?if ($zoek[0]=="IE"){print "SELECTED";}?>>Ierland</OPTION>
<OPTION value="IT" <?if ($zoek[0]=="IT"){print "SELECTED";}?>>Italië</OPTION>
<OPTION value="LU" <?if ($zoek[0]=="LU"){print "SELECTED";}?>>Luxenburg</OPTION>
<OPTION value="NL" <?if ($zoek[0]=="NL"){print "SELECTED";}?>>Nederland</OPTION>
<OPTION value="AT" <?if ($zoek[0]=="AT"){print "SELECTED";}?>>Oostenrijk</OPTION>
<OPTION value="PT" <?if ($zoek[0]=="PT"){print "SELECTED";}?>>Portugal</OPTION>
<OPTION value="ES" <?if ($zoek[0]=="ES"){print "SELECTED";}?>>Spanje</OPTION>
<OPTION value="GB" <?if ($zoek[0]=="GB"){print "SELECTED";}?>>Verenigd - Koninkrijk</OPTION>
</SELECT>
</td></tr>
<tr><td class="filtertekst">Regio</td>
<td class="filteroptie">
<div id="regiodiv">
<select id="regio" name="regionum">
<option value="0">Selecteer eerst een land </option>
</select>
</div>
</td></tr>
<tr><td class="filtertekst">Subregio</td>
<td class="filteroptie">
<div id="subregiodiv">
<select id="subregio" name="subregionum">
<option value="0">Selecteer eerst een regio</option>
</select>
</div>
</td></tr>
</table>
de eerste hulpfile:findregio2.php (werkt als je hem appart oproept.)
PHP:
<?
$l=$_GET['country'];
$language="NL";
$taalstring="Region_".$language;
$con = mysql_connect(**********************);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db(************, $con);
$sql=*******************;
//echo $sql;
$result=mysql_query($sql);
?>
<select id="regio" name="regionum" onchange="getSubregio(<?=$l?>,this.value)">
<option>maakt niet uit</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['idRegions']?>><?=$row['taal']?></option>
<? } ?>
</select>
tweede php hulpfile findsubregio2.php die niet uitgevoerd wordt doordat hat js commando niet aangeroepen wordt?
PHP:
<?
$l=$_GET['country'];
$r=$_GET['state'];
$language="NL";
$taalstring="Subregion_".$language;
$con = mysql_connect(***************);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db(********, $con);
$sql=***********************;
echo $sql;
$result=mysql_query($sql);
?>
<select id="subregio" name="subregionum">
<option>maakt niet uit</option>
<? while($row=mysql_fetch_array($result)) { ?>
<option value=<?=$row['idSubRegions']?>><?=$row['taal']?></option>
<? } ?>
</select>
waarom wordt getSubregio niet uitgevoerd?
Laatst bewerkt: