views:

12

answers:

2

Hi

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

A: 

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.

BBonifield
Hi, thanks for that, i can get the value of the select (ie it is recongized) but when i select yes and press next to go to the next part it just scrolls to white, #stepForm is the element the accordion is attached to, i will add more code to my OP
David
A: 

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;
        }
    });
  }
});
David