如果选择选项等于某个选项,则跳过手风琴部分

发布于 2024-09-24 11:58:59 字数 741 浏览 6 评论 0原文

我最近一直在研究一个相当复杂的手风琴/表单,并且在一个步骤中有一个选择下拉框,如果用户使用选择框选择了选项“是”,我希望它跳到最后一部分(7)。

我尝试使用下面的代码,但它似乎不起作用,它只是用空的空白替换了手风琴,就像它找不到它正在寻找的东西或正在引用未知的东西一样。

    $('#perfect-condition').change(function() {
    var name = this.value;

    if(name == 'Yes')
    {
        if (v.form()) {
            $("#stepForm").accordion("activate", 7);
            current = 7;
        }
    }
});

编辑: 我正在制作一个基于 jquery 网站上的演示之一的手风琴,它是使用 jquery 验证的多部分表单,但这不是问题,手风琴使用 ul/li 结构,可以轻松地在面板之间移动,下面是我用作下一个按钮的代码:

    $(".open3").click(function() {
  if (v.form()) {
    accordion.accordion("activate", 3);
    current = 3;
  }
});

我之前的代码应该在这个函数内吗?抱歉,我真的不是 jquery 专家...

如果有人可以阐明这一点并帮助我,我将非常非常感激:)

I have been working on quite a complex accordion/form recently and have a select dropdown box on one step, i want it to skip to the last section (7) if the user has chosen the option yes with the select box.

i tried to use the code below but it didn't seem to work, it just replaced the accordion with empty white space like it couldn't find what it was looking for or was referencing something unknown.

    $('#perfect-condition').change(function() {
    var name = this.value;

    if(name == 'Yes')
    {
        if (v.form()) {
            $("#stepForm").accordion("activate", 7);
            current = 7;
        }
    }
});

EDIT:
i am making an accordion based on one of the demos on the jquery site, it is a multipart form using jquery validation, that isn't the issue though, the accordion is using a ul/li structure and can travel between the panels with ease, below is the code i am using as the next buttons:

    $(".open3").click(function() {
  if (v.form()) {
    accordion.accordion("activate", 3);
    current = 3;
  }
});

should my previous code be inside of this function? sorry not a jquery expert really...

if anyone could shed some light on this and help me out i would be very very grateful :)

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

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

发布评论

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

评论(2

怎樣才叫好 2024-10-01 11:58:59

至少,您将选择列表的选定值拉错了。

$('#perfect-condition').change(function() {
  var name = $(this).val();

  if(name == 'Yes')
  {
      if (v.form()) {
          $("#stepForm").accordion("activate", 7);
          current = 7;
      }
  }
});

但实际的手风琴更新调用似乎是合法的,假设 #stepForm 实际上是手风琴。如果仍然不起作用,请在原始帖子中添加更多代码和 HTML。

At the very least, you're pulling the selected value of the select list wrong.

$('#perfect-condition').change(function() {
  var name = $(this).val();

  if(name == 'Yes')
  {
      if (v.form()) {
          $("#stepForm").accordion("activate", 7);
          current = 7;
      }
  }
});

But the actual accordion update call seems legit, assuming that #stepForm is actually the accordion. If it still doesn't work, add more code and HTML to your original post.

故人爱我别走 2024-10-01 11:58:59

好吧,似乎现在可以工作了,对实际链接做了一些更改,如果您需要解决类似的问题,请参阅下面的代码...

    $(".open3").click(function() {
  if (v.form()) {
    $('#perfect-condition').attr('value', function() {
        var name = $(this).val();

        if(name == 'Yes')
        {
            $("#stepForm").accordion("activate", 6);
            current = 6;
        }
        else
        {
            accordion.accordion("activate", 3);
            current = 3;
        }
    });
  }
});

Ok seems to have it working now, made some changes to the actual link, see code below if you need to fix a similar problem...

    $(".open3").click(function() {
  if (v.form()) {
    $('#perfect-condition').attr('value', function() {
        var name = $(this).val();

        if(name == 'Yes')
        {
            $("#stepForm").accordion("activate", 6);
            current = 6;
        }
        else
        {
            accordion.accordion("activate", 3);
            current = 3;
        }
    });
  }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文