我在code
下方使用,显示???仅代替result
。你可以帮我解决下面表格中的error
吗?消息显示空白结果,如??格式。任何帮助? -
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="12%"> </td>
<td width="2%"> </td>
<td width="2%"> </td>
<td width="2%"> </td>
<td width="16%"> </td>
<td width="66%"> </td>
</tr>
<tr>
<td><img src="images/australia1.jpg" width="132" height="70"></td>
<td> </td>
<td> </td>
<td> </td>
<td><select name="select">
<option>Select Course Type</option>
<option>Under Graduate</option>
<option>Post Graduate</option>
</select>
</td>
<td><div id="message"></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<script type="text/javascript" language="javascript">
var messages = {
Under Graduate: 'UG text is here',
Post Graduate: 'PG text is here'
}
$('select').change(function() {
$('#message').text(messages[$(this).val()]);
});
</script>
答案 0 :(得分:0)
您的邮件对象中存在语法错误。您需要在其中包含空格的键周围使用引号:
var messages = {
'Under Graduate': 'UG text is here',
'Post Graduate': 'PG text is here'
}
答案 1 :(得分:0)
我认为您只缺少value
属性并使用单字标识符
<option vale="under_graduate">Under Graduate</option>
var messages = {
under_graduate: 'UG text is here',
val1: 'PG text is here'
}
</script>
答案 2 :(得分:0)
<script type="text/javascript" language="javascript">
var messages = {
under: 'UG text is here',
post: 'PG text is here'
}
$('select').change(function() {
if($(this).val() != '')
$('#message').text(messages[$(this).val()]);
});
</script>
<select name="select">
<option value="">Select Course Type</option>
<option value="under">Under Graduate</option>
<option value="post">Post Graduate</option>
</select>
答案 3 :(得分:0)
试试这个
<script type="text/javascript" language="javascript">
$('#select').change(function() {
var selectVal = $('#select :selected').val();
$(#message).text(selectVal);
});
</script>
并替换
<select name="select">
通过
<select id="select">