If Statement Radio Button Help?
The function below hides and shows the rest of my form fields (when I don't use the if statement). I wanted to try to make an if statement so that when I reload the page, I don't have to reselect the radio button when it is not null. I want to have an if statement that says, if the radio buttons are null, hide the form fields. If it is not null, just maintain the current state. Unfortunately, I couldn't get the function below to work.
- $(function (){
if ($('input.radioalign[value=""]')) {
$('fieldset[id$=Form]').hide());
}
$('input[name=selector]').click(function() {
var id = '#' + this.id.replace(/Button/, 'Form');
$('fieldset[id$=Form]').not(id).hide();
$(id).show();
});
});
Here is are the corresponding buttons in HTML.
- <p>
<label for="selector" class="leftcolalign">What am I? *</label>
<input id="entButton" class="radioalign" type="radio" name="selector" checked="checked" value="Entrepreneur"<?php print $entrepreneur; ?>>
<label for="entrepreneur" id="entrepreneur">Entrepreneur</label>
<input id="invButton" class="radioalign" type="radio" name="selector" checked="checked" value="Investor"<?php print $investor; ?>>
<label for="investor" id="investor">Investor</label>
</p>