> jquery variables, quotes, string contenation etc.

jQuery doesn't *have* variables, quotes, or string concatenation.

Those are part of JavaScript, not jQuery.

I'm not being nitpicky. If you keep this fact in mind it will make it much
easier to troubleshoot.

You could spend days throwing thing at jQuery and seeing if they work or
not, without ever stumbling upon the real problem.

Instead, since you have one known good string, take advantage of the fact
that you're simply trying to create another string identical to that one:

  var good = "select[name='dllViewSelector_Search_0'] option:selected";
  var test = ... your test concatenation here ...;
  alert(
      '{' + good + '}\n' +
      '{' + test + '}\n' +
      ( good === test )
  );

Now you should get an alert box with two strings, one above the other, and
true or false at the bottom. I put curly braces around both strings in the
alert box to make sure any leading or trailing whitespace is visible.
(jQuery would ignore those anyway, but it's a good habit if you're doing
something like this.)

This should make it much more visible where your string concatenation is
going wrong. If you get two identical strings in the alert box with a "true"
at the bottom, then you can be sure that your code will work with jQuery as
well.

-Mike

> From: LinkGuru
> 
> The following statement is proven to work:
> 
> p_viewSelector=$("select[name='dllViewSelector_Search_0']
option:selected").text();
> 
> But now I need to adapt it so the Search_0 component is replaced by a
> variable (because it isn't always going to be Search_0 at that point.
> So I've got
> 
>                               curSelector="ddlViewSelector"+idCurrent;
>                               
> p_viewSelector=$("select[name='"+curSelector+"']
option:selected").text();// single quote just before the 1st + and
> just after the 2nd +
>                                 //idCurrent might be Search_0, but
> could be Search_<any integer>
> 
> (and also tried lots of other combinations e.g.
> 
>                               
> curSelector="'ddlViewSelector'"+idCurrent;// dbl quote sing
> quote ....sing quote dble quote
>                               
> p_viewSelector=$("select[name="+curSelector+"]
> option:selected").text();
> )
> 
> So, if anyone is expert with jquery variables, quotes, string
> contenation etc. who can solve this one, it would be greatly
> appreciated!
> 

Reply via email to