|
|
 Rank: Enthusiast
Joined: 2/28/2008 Posts: 36 Location: South Africa
|
Hi all
I am busy writing a usercontrol page. as part of it, I am doing some js coding with jquery. if I take a textbox with id"txtdate", when it is rendered it has an id of "Register_4_txtdate". The "register" is obviously the usercontrol page. A Couple of questions:
1. Where does the "4" come from. Is it random, and if I create a new page based upon this control will the "4" change (i am guessing yes).
2. How I can I access this control through javascript. I have tried $("#<%= txtdate.ClientID %>") using jquery, but this did not work, but I am guessing this only works during rendering.
Any help will be much appreciated
Thanks Andrew
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
Hi andrew, How about $("input[id*=txtdate]") Hope this helps. Regards. /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
 Rank: Enthusiast
Joined: 2/28/2008 Posts: 36 Location: South Africa
|
Hi Dirk
That worked perfectly thanks. Seems I need to brush up on my jquery syntax. On reading the docs I see that it "Matches elements that have the specified attribute and it contains a certain value"
Therefore I guess that I must make sure I do not have an element called "txtdate2" etc
Thanks again Andrew
|
|
 Rank: Umbracoholic
Joined: 9/27/2007 Posts: 1,123 Location: Belgium
|
hi andrew, You're right about the 'contains a certain value'. But there are other methods/selectors besides *, which are $ en ^, which behave exactly the same as in reg expressions. But you're right, it could become an issue if you don't really now the exact name of the element upfront. Regards, /Dirk
level 1 & 2 certified - umbraco MVP 2008/2009 - umbraco blog at netaddicts.be - working on an integrated forum4umbraco
|
|
|
Guest |