How do I insert a variable into a the name of a control using Jqueryhttp://forums.asp.net/t/1768778.aspx/1?How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryTue, 14 Feb 2012 03:39:04 -050017687784828896http://forums.asp.net/p/1768778/4828896.aspx/1?How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryHow do I insert a variable into a the name of a control using Jquery <p>I have several controls wtih only one part of the middle being different and but want to use one function to handle all of them.</p> <p>I have tried to do the following:</p> <p>I have a textbox called TxtAddDriverModel and another one called TxtAddPassengerModel</p> <p>I am trying to access the two different textboxes by inserting the clubType in the string but it doesn't work.&nbsp; What do I do?</p> <p>var Type = 'Driver'</p> <p>if (!(&#36;(&quot;#&lt;%=TxtAdd&quot; &#43; Type &#43; &quot;Model.ClientID %&gt;&quot;).val() == 'Add New MODEL Here!'))</p> 2012-02-13T03:12:54-05:004828908http://forums.asp.net/p/1768778/4828908.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p></p> <blockquote><span class="icon-blockquote"></span> <h4>JAYHAWKER</h4> <p></p> <p>var Type = 'Driver'</p> <p>if (!(&#36;(&quot;#&lt;%=TxtAdd&quot; &#43; Type &#43; &quot;Model.ClientID %&gt;&quot;).val() == 'Add New MODEL Here!'))</p> <p></p> </blockquote> <p></p> <p></p> <p>hi try this</p> <p>var Type=&quot;Driver&quot;;</p> <p>var id=&quot;#txtadd&quot;&#43;Type&#43;&quot;&lt;%=Model.ClientID %&gt;&quot;;</p> <p>if(!&#36;(id).attr('value')=='Add New Model Here')</p> <p>{</p> <p>// Execute code</p> <p>}</p> <p></p> 2012-02-13T03:36:54-05:004829002http://forums.asp.net/p/1768778/4829002.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p>Hi,</p> <p>Try this-</p> <pre class="prettyprint">var Type = 'Driver' if (!($('input[id*=TxtAdd' &#43; Type &#43; 'Model]').val() == 'Add New MODEL Here!'))</pre> 2012-02-13T05:02:23-05:004829963http://forums.asp.net/p/1768778/4829963.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p>Thanks!</p> <p>Using the new notation, how would i get the value of a dropdownlist.</p> <p>For example, I would use the following before:</p> <pre class="prettyprint">if ($(&quot;#&lt;%=ddlMake.ClientID %&gt; option:selected&quot;).val() == -1)</pre> 2012-02-13T14:31:53-05:004830009http://forums.asp.net/p/1768778/4830009.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p>Hi,</p> <p></p> <blockquote><span class="icon-blockquote"></span> <h4>JAYHAWKER</h4> if (&#36;(&quot;#&lt;%=ddlMake.ClientID %&gt; option:selected&quot;).val() == -1)</blockquote> <p></p> <p>Try this-</p> <pre class="prettyprint">if ($(&quot;select[id*=ddlMake]&quot;).val() == -1)</pre> 2012-02-13T15:05:37-05:004830132http://forums.asp.net/p/1768778/4830132.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p>Thanks, that worked great.</p> <p>How do I handlle the same thing for textobx, hiddenfield, and label.</p> <p>i.e, is it input [id*=.....</p> <p>or text[id*=.....</p> <p>or select[id*=....</p> <p>&nbsp;</p> <p>and for a div, what is it?</p> 2012-02-13T16:17:40-05:004830173http://forums.asp.net/p/1768778/4830173.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p>Hi,</p> <p>It is &#36;('tagname[id=tagid]. There can be a lots of combinations. You should study attribute selector. check the following for detail-</p> <p><a href="http://api.jquery.com/category/selectors/attribute-selectors/">http://api.jquery.com/category/selectors/attribute-selectors/</a></p> 2012-02-13T16:37:07-05:004830252http://forums.asp.net/p/1768778/4830252.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery It is sometimes hard to figure that out. For example, the hidden field shows as &lt;hidden but you use input to make it work. Thanks for your help, I did finally get it! 2012-02-13T17:26:48-05:004830712http://forums.asp.net/p/1768778/4830712.aspx/1?Re+How+do+I+insert+a+variable+into+a+the+name+of+a+control+using+JqueryRe: How do I insert a variable into a the name of a control using Jquery <p>Hi,</p> <p>You always need to check the rendered html content to work with jQuery.</p> <p></p> 2012-02-14T03:39:04-05:00