在填充第一个下拉菜单之前禁用第二个下拉菜单

发布于 2024-09-01 04:01:10 字数 1263 浏览 0 评论 0原文

在第一个(选择类别)具有有效选择之前,我需要将第二个跳转框(选择子类别)灰显。.这是当前的代码..谢谢大家

    <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>

I need to grey out the second jump box (Select a Subcategory) before the first (Choose a Category) has a valid selection ..Here is the current code.. thanks guys

    <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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-09-08 04:01:10

保持禁用状态,直到 $.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");
    }   
}

Keep it disabled until $.ajax's success callback fires:

<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");
    }   
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文