Solved

Quick JQuery syntax issue

Posted on 2013-12-16
2
207 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
ID: 39721167
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
ID: 39721178
Ah! - a bit obvious now I can see the solution - but isn't that always the case?
Many thanks,

Regards
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn how to dynamically set the form action using jQuery.
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)

809 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