안녕하세요, 저는 드롭 다운 선택에 따라 표시되고 숨겨져있는 요소를 전환하는 데 문제가 있습니다. 나는 여러 가지 일을 시도했지만 그 일을하기 위해 볼 수는 없습니다.자바 스크립트를 사용하여 드롭 다운 선택에 따라 테이블 표시
UPDATE: This is the new code that I tried out, but still nothing is working
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
$(document).ready(function() {
$('#TypeOfChange').change(function() {
if ($(this).val() == 'Option 1') {
$('#Table1').css({'display': 'block'});
$('#RequestTypeTableTR').css({'display': 'block'});
} else {
$('#Table1').css({'display': 'none'});
$('#RequestTypeTableTR').css({'display': 'none'});
}
if ($(this).val() == 'Option 2') {
$('#Table2').css({'display': 'block'});
$('#RequestTypeTableTR').css({'display': 'block'});
} else {
$('#Table2').css({'display': 'none'});
$('#RequestTypeTableTR').css({'display': 'none'});
}
});
});
</script>
</head><body>
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
<table border="0" class="form">
<tr valign="baseline" class="clear">
<td align="right" valign="middle" nowrap="nowrap" class="style8"><h2>General Information</h2></td>
<td valign="baseline"> </td>
</tr>
<tr valign="baseline" class="clear">
<td align="right" valign="top" nowrap="nowrap" class="style9">
<p>*Request Type:</p>
</td>
<td valign="top" class="style8">
<p>
<span id="spryselect5">
<label>
<select name="TypeOfChange" id="TypeOfChange">
<option value="Please Select" selected="selected">Please Select</option>
<option value="Option 1">Option 1</option>
<option value="Option 2">Option 2</option>
<option value="Option 3">Option 3</option>
<option value="Option 4">Option 4</option>
<option value="Option 5">Option 5</option>
</select>
</label>
<span class="selectInvalidMsg">Please select a valid item.</span><span class="selectRequiredMsg">Please select an item.</span>
</span>
<span class="style1">*</span>
</p>
</td>
</tr>
<tr style="display:none" id="RequestTypeTableTR" valign="baseline" class="clear">
<td valign="middle" nowrap="nowrap"> </td>
<td valign="baseline">
<table style="display:none" id="Table1" width="100%">
<tr>
<td Colspan="2" align="right" valign="middle" nowrap="nowrap" class="style8"><h2>Patient Safety1</h2></td>
</tr>
</table>
<table style="display:none" id="Table2" width="100%">
<tr>
<td Colspan="2" align="left" valign="middle" nowrap="nowrap" class="style8"><h2>Patient Safety2</h2></td>
</tr>
</table>
</td>
</tr>
</table></FORM>
'옵션 1'에 대한 코드가'change' 함수 외부에 있습니다. – callback