问题描述
我们有一个包含多行输入的HTML表单.我们使用默认信息填充该表.我们希望用户在使用默认信息填充表单后,将注意力集中在第一个非空白列上.
我们将ASP.NET与用于插入5250屏幕并将其转换为ASP.NET网站的工具一起使用.这是其中两条输入线的样子.共有10个:
setCursorAtTheEnd(this,event)不起作用.
We have an HTML form with multiple lines of input. We populate this table with default information. We want to user to have focus on the first non-blank column after the form is popluated with the default information.
We are using ASP.NET with a tool that is interpeting our 5250 screens and converting them to ASP.NET web sites. Here is what 2 of the input lines look like. There is a total of 10:
setCursorAtTheEnd(this,event) is not working.
<mdf:DdsCharField id="RESPONC_DSC01" runat="server" onfocus="setCursorAtTheEnd(this,event)"
CssClass="DdsCharField"
Length="67"
style=" POSITION: absolute; LEFT: 91px; TOP: 264px;"
Alias="DSC01"
Usage="Both"
VirtualRowCol="12,10"
ErrorMessageId="UMS0012 RWMSGF 74 : 74"
Width="604px"
TabIndex="5" />
<mdf:DdsCharField id="RESPONC_DSC02" runat="server"
CssClass="DdsCharField"
Length="67"
style=" POSITION: absolute; LEFT: 91px; TOP: 288px;"
Alias="DSC02"
Usage="Both"
VirtualRowCol="13,10"
Width="604px"
TabIndex="6" />
[edit]从OP的答案中移出了其他信息
我是团队项目的高级程序员.因此,此信息正在传递给我.我收到了以下更新:
下面的代码将光标定位在最后一个字符之后,但是现在我们希望它向右移动1个空格:
(代码只是后面的原始代码的重复)[/edit]
Java脚本:
[edit] Moved the additional information from OP''s answer here
I am working as a senior programmer on a team project. So this information is being passed to me. I received an update, which follows:
The code below positions the cursor after the last character but now we want it to go 1 space more to the right:
(code was just a repetition of the original that follows)[/edit]
Java script:
function setCursorAtTheEnd(aTextArea, aEvent) {
var end = aTextArea.value.length;
if (aTextArea.setSelectionRange) {
setTimeout(aTextArea.setSelectionRange, 0, [end, end]);
} else {
var aRange = aTextArea.createTextRange();
aRange.collapse(true);
aRange.moveEnd('character', end);
aRange.moveStart('character', end);
aRange.select();
}
// aEvent.preventDefault();
return false;
}
推荐答案
这篇关于用javascript聚焦到列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!