2010-10-15 84 views
0

基本上,下面的函数是一个选择一个下拉列表的变化的监听器。我希望光标移动到页面上的下一个字段以及下面的函数被执行。我如何在Javascript中做到这一点?页面上的下一个字段是ExtJs文本框。移动光标到下一个字段使用Javascript

function changeVehicleCondition() { 
     var ValuationSource = getCurrentValuationSource(); 
     var vehicleConditionId = vehiclePnl.VehicleConditions.getValue(); 

     if (ValuationSource == 0) { 
      vehiclePnl.VehicleConditionId.setValue(0); 
     } else { 
      vehiclePnl.VehicleConditionId.setValue(vehicleConditionId); 
     } 
    } 

编辑:焦点()不为我工作,因为我想这已经:

vehiclePnl.Mileage.focus(); 

没有运气..

回答

1

对于ExtJS的你apparentley必须这样做:

focus(true, false); 

真正告诉它来选择下一个字段的文本和虚假告诉它是否要延迟。它实际上并没有为我工作,但我认为这是因为我的控件不匹配,但这是做它的代码。

0

这是一个没有ExtJS的

知识
<select id="listen">...</select> 
<input id="focus" /> 
<script type="text/javascript"> 
document.getElementById('listen').onchange = function() { 
    changeVehicleCondition() 
    document.getElementById('focus').focus() 
} 
</script> 

脚本标记可以在选择后的任何位置。你也可以这样来做:

<select id="listen" onchange="changeVehicleCondition(); document.getElementById('focus').focus()">...</select> 
<input id="focus" /> 
+0

然后在下一个字段后到达字段,但它在当前字段上保持突出显示,并且当您立即输入时,字符仍会进入您所在的字段,因此它不起作用。 ExtJs可能会让事情变得很奇怪...... – Scott 2010-10-15 18:43:06

0

假设您的表单面板被定义为变量“vehiclePnl”,并且您想要关注的下一个字段的名称属性为“里程”。 而不是使用以前的代码

vehiclePnl.Mileage.focus(); 

然后当我使用集中它把“专注”一个接一个的领域,因为当我打“标签”时,实际上你应该使用这个代码波纹管

vehiclePnl.getForm().findField("Mileage").focus(); 
相关问题