即时尝试填充基于其他选择的选择,当我尝试时,教程完美无缺
我在标题
中有这段代码 <script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$(".country").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;
$.ajax
({
type: "POST",
url: "ajax_city.php",
data: dataString,
cache: false,
success: function(html)
{
$(".city").html(html);
}
});
});
});
</script>
并在体内
<div style="margin:80px">
<label>Country :</label> <select name="country" class="country">
<option selected="selected">--Select Country--</option>
<?php
$sql=mysql_query("SELECT * FROM master_cat_wine");
while($row=mysql_fetch_array($sql))
{
$id=$row['id'];
$data=$row['nome'];
echo '<option value="'.$id.'">'.$data.'</option>';
} ?>
</select> <br/><br/>
<label>City :</label> <select name="city" class="city">
<option selected="selected">--Select City--</option>
</select>
</div>
但是当我尝试创建一个带有表的表单来组织布局时,我不能使用这个代码在主体和相同的标题中
<form action="#" method="post">
<table width="717" border="0">
<tr><td>
<select name="country" id="country">
<option selected="selected">--Select City--</option>
<?php
$result = mysql_query("SELECT * FROM master_cat_wine");
while ($row = mysql_fetch_array($result)){
echo '<option value="' .$row['id'].'">'.$row['nome'].'</option>';}?>
</select>
</td></tr>
<tr><td class="fontR">
<div align="right">Sub-Category</div></td><td>
<select name="city" id="city">
<option selected="selected">--Select City--</option>
</select>
</td></tr></table></form>
我如何访问表单内表格内的值?