PHPbeginner
18-01-2005, 14:42
Hi
Ich habe eine Drop-Down-Liste mit verschiedenen Ländern. Ich möchte das sich die Flagge automatisch ändert wenn man ein anderes Land auswählt. Irgendwie will aber die JS Funktion die "imgid" nicht übernehmen. Weiss jemand was ich falsch mache?
Das JS Script im Header:
function changeCountry(imgid,countryid)
{
select_value = document.getElementByID(countryid).value;
path = 'images/countries/';
if (select_value) document.getElementById( imgid ).src = path + select_value + '.GIF';
else document.getElementByID( imgid ).src = path + 'NOC.GIF';
}
Die Drop-Down-Liste:
<select name="country2" id="country2" class="inputfield" onchange="changeCountry(cimg2,country2)">
<option value="NOC" selected>Choose Country</option>
<option value="US">United States</option>
[...]
</select>
<img src="images/countries/NOC.GIF" id="cimg2" alt="">
Ich habe eine Drop-Down-Liste mit verschiedenen Ländern. Ich möchte das sich die Flagge automatisch ändert wenn man ein anderes Land auswählt. Irgendwie will aber die JS Funktion die "imgid" nicht übernehmen. Weiss jemand was ich falsch mache?
Das JS Script im Header:
function changeCountry(imgid,countryid)
{
select_value = document.getElementByID(countryid).value;
path = 'images/countries/';
if (select_value) document.getElementById( imgid ).src = path + select_value + '.GIF';
else document.getElementByID( imgid ).src = path + 'NOC.GIF';
}
Die Drop-Down-Liste:
<select name="country2" id="country2" class="inputfield" onchange="changeCountry(cimg2,country2)">
<option value="NOC" selected>Choose Country</option>
<option value="US">United States</option>
[...]
</select>
<img src="images/countries/NOC.GIF" id="cimg2" alt="">

