Solved

Quick JQuery syntax issue

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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
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…

724 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