Solved

Quick JQuery syntax issue

Posted on 2013-12-16
2
206 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help with jQuery plugin 10 28
Put radio button in my form but already has components from my database 4 62
Passport Expiry 3 44
Jquery keyup 4 18
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
The viewer will learn how to dynamically set the form action using jQuery.
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…

770 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