1

I have a Select Option

<select class="input_select" name="customer_type" id="central_company">
    <option value="standard">Standard</option>
    <option value="central">Central Station</option>
</select>

and a button

<div class="standardbutton">
     <label class="button_label">
         <input type="submit" class="standardbutton" name="button1" value="Submit Form" />
     </label>
</div>

That when clicked uses this Jquery

// Show Special Form Elements
$(".cleantestbox").hide();
$('#central_company').change(function() {
    var option = $(this).find('option:selected');
    $('.cleantestbox').toggle(option.hasClass('central'));
    $('.standardbutton').toggle(option.hasClass('standard'));
}).change();

to hide the standard button class and show a div called .cleantestbox but it doesn't seem to be working. Any ideas it worked before but can't seem to find whats causing it not to work.

4
  • 2
    What kind of errors do you get in the console?
    – dezman
    Feb 13, 2013 at 16:24
  • 1
    In what way is it not working? Put your code in a fiddle: jsfiddle.net
    – isherwood
    Feb 13, 2013 at 16:24
  • No Errors just when I select the central nothing happens and the standardbutton div doesn't show up by default either
    – Nexus9988
    Feb 13, 2013 at 16:28
  • Here's your code: jsfiddle.net/DdMZV
    – isherwood
    Feb 13, 2013 at 16:33

1 Answer 1

1
// Show Special Form Elements
$(".cleantestbox").hide();
$('#central_company').change(function() {
  if ($(this).val() == 'central') {
    $('.cleantestbox').show();
    $('.standardbutton').hide();
  } else {
    $('.cleantestbox').hide();
    $('.standardbutton').show();
  }
});
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.