Apologies. A couple of silly errors. 1) its dllViewSelector not ddlViewSelector (I do cut and paste a lot to save such mistakes, normally - honest). And (thanks James), there was a missing underscore. Thanks for all the other contributions to this including Michael Geary's sensible advice. It's the pressure of a deadline making me a bit too hasty.
On Mar 31, 9:20 pm, Ricardo <ricardob...@gmail.com> wrote: > The quotes in the attr selector are not required, try: > $('select[name=ddlViewSelector_'+idCurrent+'] option:selected').text > (); > > On Mar 31, 2:47 pm, LinkGuru <i...@legalanalytics.co.uk> wrote: > > > Can anyone help on this one? ......... > > > 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!