Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
6 replies
Subscribers
8 subscribers
Views
2941 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
User Interface
Hi, I am able to set focus to a particular textbox onload of a form u
senthilar
over 11 years ago
Hi,
I am able to set focus to a particular textbox onload of a form using the below code :
document.getElementById("textControl_fd_component_"+window.FormDesigner.runtimeNamespace+"requestComments").focus();
But this doesn't work for textarea. The page throws an error at run-time. Is it because of "textControl_fd_component"? What do I replace that with?...
OriginalPostID-99124
OriginalPostID-99124
Discussion posts and replies are publicly visible
0
Eduardo Fuentes
Appian Employee
over 11 years ago
For the paragraph component here's an example
var settingfocus = document.getElementsByName("plainTextControl_"+id);
settingfocus[0].focus()
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
senthilar
over 11 years ago
That works like a charm! Thank you Eduardo!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
padmanabhanv
over 11 years ago
What would be the syntax for a rich text control; the above code does not work for rich text fields
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
senthilar
over 11 years ago
Eduardo, this code worked fine for plain forms where there are not much fields. But I faced the following behaviors:
1) In a form having lots of controls (around 30) - the code didn't bring the focus to the intended textarea.
2) In a form which is assigned to a group - when a person picks up the task, the following error message is shown in an alert
"An exception was thrown by the custom event "load" with rule "{var settingfocus = document.getElementsByName(\\"plainTextControl_\\"+\\"requestComments\\");settingfocus[0].focus()}"."
Could it be because before the person accepts the task (by hitting the Accept button on top of the page), the form is readonly and so the element is not available for focus?
Any workarounds available?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Eduardo Fuentes
Appian Employee
over 11 years ago
That worked for me even with 30 components but it could be that you are facing a race conditions (the components are not available yet when the code is executed).
My suggestion would be:
1. Switch to this other syntax
$("#plainTextControl_fd_component_" + window.FormDesigner.runtimeNamespace + id).get(0).focus();
2. This means your line will now be
$("#plainTextControl_fd_component_" + window.FormDesigner.runtimeNamespace + "requestComments").get(0).focus();
3. If the issue persists wrap it in a setTimeout to delay its execution. This example dealys it for 50ms
setTimeout(function() {$("#plainTextControl_fd_component_" + window.FormDesigner.runtimeNamespace + "requestComments").get(0).focus();}, 50);
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
senthilar
over 11 years ago
Thank you Eduardo!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel