選択項目のhtmlリストがあります。値 name: otherがあります。これを選択すると、テキスト入力が表示されます。
以下は私のコードです。ユーザーが 以外のオプションを選択するother
と、テキスト入力は非表示になります。ユーザーが選択から選択したときに、このテキスト フィールドを表示するにはどうすればよいですかother
。
<td>
Interest <span style="color:#F00;">*</span>
</td>
<td>
<select name="interest" id="travel_arriveVia" onchange="showfield(this.options[this.selectedIndex].value)">
<option value="art" <?php if ($g_interest=="art" ) echo 'selected = "selected"'; ?>>Art</option>
<option value="litteratures" <?php if ($g_interest=="litteratures" ) echo 'selected = "selected"'; ?>>Litteratures</option>
<option value="business" <?php if($g_interest=="business" ) echo 'selected = "selected"'; ?>>Business</option>
<option value="internet" <?php if($g_interest=="internet" ) echo 'selected = "selected"'; ?>>Internet</option>
<option value="other_interest" <?php if($g_interest=="internet" ) echo 'selected = "selected"'; ?>>Other</option>
</select>
<script type="text/javascript">
function showfield(name) {
if (name == 'other_interest') document.getElementById('div1').innerHTML = '<input type="text" name="other_interest" class="trother" />';
else document.getElementById('div1').innerHTML = '';
}
</script>
<div id="div1"></div>
</td>
ありがとう。