?
Solved

jQuery function not working

Posted on 2011-02-14
3
Medium Priority
?
337 Views
Last Modified: 2012-05-11
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:
$(".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();
}
})

Open in new window


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>

Open in new window

0
Comment
Question by:Dzynit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
wellhole earned 2000 total points
ID: 34889147
Did you run the script after the body was loaded?
0
 
LVL 14

Author Closing Comment

by:Dzynit
ID: 34889241
Ok, that worked. I tried adding it right after the fields assuming that would work. Thanks much!
0
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 34889301
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


$(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();
 }
 });
});

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question