Heather Ritchey
asked on
jQuery function not working
I'm terrible with jQuery. This is suppose to show the input box only when Other is selected from the dropdown, but it's not calling the function at all. Can someone give me a hand? FF isn't showing any errors either.
script:
Fields:
script:
$(".spacingbows").change(function(){
alert('function called');
//set the select value
var val = $(this).val();
if(val != "Other") {
$(this).nextAll('.spacingbowsother').hide();
} else {
$(this).nextAll('.spacingbowsother').show();
}
})
Fields:
<td width="198"><select size="1" id="R-4_h" class="spacingbows" name="R-4.h-Spacing-Between-Bows">
<option<?php echo $x4h1;?> value="">Select one:</option>
<option<?php echo $x4h2;?> value="4'">4'</option>
<option<?php echo $x4h3;?> value="5'">5'</option>
<option<?php echo $x4h4;?> value="6'">6'</option>
<option<?php echo $x4h5;?> value="Other">Other</option>
</select> <input type="text" id="R-4_o" class="spacingbowsother" name="R-4.o-Spacing-Between-Bows-Other" size="20" value="<?php echo $_POST['R-4_o-Spacing-Between-Bows-Other'];?>" /> on center <span class="R">*</span></td>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you won't see an error because the code is valid. What wellhole is saying is that you need to make sure your script does not run until the page has completely loaded.
try the code below. If you are running into the same problem still, please post your entire script-block
try the code below. If you are running into the same problem still, please post your entire script-block
$(document).ready(function() {
$(".spacingbows").change(function(){
alert('function called');
//set the select value
var val = $(this).val();
if(val != "Other") {
$(this).nextAll('.spacingbowsother').hide();
} else {
$(this).nextAll('.spacingbowsother').show();
}
});
});
ASKER