Solved

Quick JQuery syntax issue

Posted on 2013-12-16
2
204 Views
Last Modified: 2013-12-16
Hi,

I've got a line of Jquery code to find the text value of a selected item in a drop down list:

		var currentId = $(this).attr('id').substring(5);
		if ($('#feeid + currentId option:selected').text() == 'My Fee Is') {

Open in new window


It doesn't work, however this does:

		var currentId = $(this).attr('id').substring(5);
		if ($('#feeid1 option:selected').text() == 'My Fee Is') {

Open in new window


So using the '+ currentid' is causing the issue. I have confirmed the currentid has a correct value. How do I code this? I have searched the internet but it's so specific I can't find an answer that helps me.

I am assuming that you can place the '#feeid + currentId' in some parenthesis? I may be totally wrong though. :)

Regards
0
Comment
Question by:splanton
2 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 300 total points
Comment Utility
The syntax error should be solved with this:
if ($('#feeid' + currentId + ' option:selected').text() == 'My Fee Is') {

Open in new window


You weren't concatenating the values correctly.
0
 
LVL 2

Author Closing Comment

by:splanton
Comment Utility
Ah! - a bit obvious now I can see the solution - but isn't that always the case?
Many thanks,

Regards
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now