Combining Two jQuery .val() Results Into Variable

I'm sure this is fairly elementary; however, I just can't get it to work. It's a two step process. First, I want to combine the values of two dropboxes into a string. Second step, I need to display any ID field found in a table row that matches that string. Here are the two lines of code; however, something is not quite working out for me yet. Any help would be greatly appreciated!

var $result = $('#provider').val() + $('#grade').val();
$('tr[id*=\"$result\"]').show();

Answers


The problem isn't combining the variables — the string concatenation should be just fine.

JavaScript doesn't perform variable replacement in strings, the way PHP does. Here's the fix:

var result = $('#provider').val() + $('#grade').val();
$('tr[id*="' + result + '"]').show();

Try this:

$('tr[id*="' + $result + '"]').show();

Need Your Help

SQLite: Transposing results of a GROUP BY and filling in IDs with names

python sqlite3 pivot

My question is rather specific, if you have a better title please suggest one. Also, formatting is bad - didn't know how to combine lists and codeblocks.

calling fragment from activity throws null pointer exception- Android

java android android-fragments

I am trying to call a List fragment from fragment activity, I m getting null pointer exception.Here is my code,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.