This is a migrated thread and some comments may be shown as answers.

Javascript - dynamic control find

3 Answers 261 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kamil
Top achievements
Rank 1
Kamil asked on 15 Feb 2012, 03:53 PM
Hello!
I want to find control using javascript function. Im using code below:
function ChangeComboStyle(sender, eventArgs) {
            var strId = sender.get_id();
            strId = strId.slice(27); <- I get AttributeID332_6
            var splitVar = strId.split("_");
            var newId = parseInt(splitVar[0]) + 1;
 
            var newAttribute = "AttributeID" + newId.toString() + "_" + splitVar[1]; <- now I have AttributeID333_6        
            var numer = $find(newAttribute); <- numer is null

Control with ID = "AttributeID333_6" exist, so I have no idea why I get null :/

Is it possible to find control dynamicly?

Have a nice day
Kamil

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 17 Feb 2012, 11:21 AM
Hi,

 It depends whats the location of the control on the page, whether it is nested or visible at the time you try to find. You can also try the document.findElementById function to see if it returns a different result.

All the best,
Marin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Kamil
Top achievements
Rank 1
answered on 18 Feb 2012, 03:02 PM
When I use document.findElementById I get "undefined". Any idea how to implement this?
0
Accepted
Marin
Telerik team
answered on 20 Feb 2012, 02:29 PM
Hi,

 The proper signature of the method is document.getElementById and it takes as an argument the client-side ID of the element that you are looking for.

All the best,
Marin
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Kamil
Top achievements
Rank 1
Answers by
Marin
Telerik team
Kamil
Top achievements
Rank 1
Share this question
or