Dynamisk Select ved hjælp af javascript
Hej, jeg har et par gang lavet dynamiske select boxe som flytter options frem og tilbage.Og nu skal jeg lave det igen, så jeg vil gerne hjælpes igang.
Brugeren skal fortælle:
Hvilket land kommer han fra
og hvilket område i landet
Derfor har jeg startet med at hente alle områder og lægge dem skjult så man kan hente derfra
Her ser du det:
<?php
$countryQuery = mysql($cfgDbDatabase, "SELECT countryid FROM countries")or die($strNoDatabase);
while ($country_Array = mysql_fetch_array($countryQuery)) {
$the_countryid = $country_Array['countryid']; ?>
<select style='display: none;' multiple id="countryid<?php echo $the_countryid; ?>" name="countryid<?php echo $the_countryid; ?>">
<?php
$placeQuery = mysql($cfgDbDatabase, "SELECT * FROM places where countryid='$the_countryid' ORDER BY placeid")or die($strNoDatabase);
while ($place_Array = mysql_fetch_array($placeQuery)) {?>
<option value="<?php echo $place_Array['placeid']; ?>"><?php echo $place_Array['place']; ?></option>
<?php
} ?>
</select>
<?php
} ?>
SÅ er der gjort klar til at hente områderne frem...
Vælg Land:<br>
<select name="countryid" style="width: 99%" onChange="DelAllFrom(placeid);copy_all_from_selected_value(countryid,placeid)">
<?php
$fieldname = "country_".$languageid;
$CountryQuery = mysql($cfgDbDatabase, "SELECT $fieldname, countryid FROM countries ORDER BY country")or die($strNoDatabase);
while ($Country_Array = mysql_fetch_array($CountryQuery)) { ?>
<option value="<?php echo $Country_Array['countryid']; ?>" <?php if ($countryid == $Country_Array['countryid']){echo "selected";} else if ((!$countryid)&&($_COOKIE['countryid']==$Country_Array['countryid'])){echo "selected";} ?>><?php echo $Country_Array[$fieldname]; ?></option>
<?php
} ?>
</select>
Vælg område:<br>
<select style="width: 99%" name="placeid">
<?php
if (!$placeid){echo "<option value='' selected>".$lng_vaelg_naermeste."</option>";}
$PlaceQuery = mysql($cfgDbDatabase, "SELECT * FROM places WHERE countryid = '$countryid' ORDER BY placeid")or die($strNoDatabase);
while ($Place_Array = mysql_fetch_array($PlaceQuery)) { ?>
<option value="<?php echo $Place_Array['placeid']; ?>" <?php if($placeid==$Place_Array['placeid']){echo "selected";}?>><?php echo $Place_Array['place']; ?></option>
<?php
} ?>
</select>
-------------------------------------------------
Nu er det så at jeg skal have lavet scripts, der kopierer options fra det valgte land
