我需要在第一个(选择一个类别)有一个有效选择之前将第二个跳转框(选择一个子类别)变灰。这是当前的代码..谢谢你们
<script type="text/javascript">
\$j(document).ready(function() {
\$j('.subf_dropdown').html($j('.subf_dropdown').html());
});
function chooseForum(f, name)
{
\$j.ajax({
url: 'index.php?autocom=cats&root=' + f,
type: 'GET',
timeout: 100000,
error: function(){
alert('Oops something went wrong. Please try again');
},
success: function(xml){
\$j('.subf_dropdown').html("<optgroup label='Subcategories'> " + xml + " </optgroup>");
}
});
}
function newPostInForum(f)
{
if (f != "")
{
window.location = "http://www.xxx.co.za/?act=post&do=new_post&f=" + f;
}
}
</script>
<select name='f' class='f_dropdown' onchange="chooseForum(this.value, this); return false;">
<optgroup label="Choose a Category">
{$data}
</optgroup>
</select>
<br /><br />
<select name='subf' class='subf_dropdown' onchange="newPostInForum(this.value); return false;">
<optgroup label="Subcategories">
<option value="" selected="selected">Select a Subcategory</option>
</optgroup>
</select>
答案 0 :(得分:0)
保持禁用状态直到$ .ajax的成功回调触发:
<select name='subf' disabled="disabled"...
function chooseForum(f, name)
{
...
success: function(xml){
$j('.subf_dropdown').html("<optgroup label='Subcategories'> " + xml + " </optgroup>");
$('.subf_dropdown').removeAttr("disabled");
}
}