ユーザーが希望する「エリア」を選択すると、その特定のエリアのオプションが表示されます。私は、選択できる領域ごとに異なる隠れたドロップダウンを持っています。ユーザーが選択した後で別の「エリア」を選択すると、「area_options」が再び非表示になります。 「area_options」を隠すと、選択した値を元の値に戻すことは可能ですか?再び非表示になったときにドロップダウンリストの値をリセットする
<script type='text/javascript'>
var area = document.getElementById('area');
var area_options = document.getElementById('area_options');
if(area.value === 'selection') {
area_options.style.display = 'block';
} else if(area.value != 'selection') {
area_options.style.display = 'none';
} else {
}
</script>
<html>
<tr>
<td align='center'>
<select class='dropdown1' name='area' id='area' style='display: none;'>
<option selected disabled>Problem Area</option>
<?php
foreach($array_area as $value){
echo "<option value='$value'>$value</option>"; }
?>
</td>
</tr>
</select>
<tr>
<td align='center'>
<div id='area_options' style='display: none;'>
<select class='dropdown1' name='area_options'>
<option selected disabled>Area Options</option>
<?php
foreach($array_areaoptions as $value){
echo "<option value='$value'>$value</option>"; }
?>
</div>
</td>
</tr>
</select>
</html>
元の値では、「問題の領域」を意味しますか? –
いいえ、問題領域が再度変更された場合は、area_optionsの値をリセットします。 – JerryB