Basically the function below is a listener for a change in selection of one dropdown. I want the cursor to move to the next field on the page as well the below function is executed. How do I do this in Javascript? The next field on the page is an ExtJs textbox.
function changeVehicleCondition() {
var ValuationSource = getCurrentValuationSource();
var vehicleConditionId = vehiclePnl.VehicleConditions.getValue();
if (ValuationSource == 0) {
vehiclePnl.VehicleConditionId.setValue(0);
} else {
vehiclePnl.VehicleConditionId.setValue(vehicleConditionId);
}
}
Edi开发者_运维技巧t: focus() doesn't work for me, because I tried this already:
vehiclePnl.Mileage.focus();
with no luck..
For ExtJs you apparentley have to do this:
focus( true, false );
true tells it to select the text in the next field and false tells it whether or not to delay. it actually didn't work for me but i think thats because my controls don't match up, but that's the code to do it.
This is with no knowledge of extjs
<select id="listen">...</select>
<input id="focus" />
<script type="text/javascript">
document.getElementById('listen').onchange = function () {
changeVehicleCondition()
document.getElementById('focus').focus()
}
</script>
The script tag can be anywhere after the select. You can also do it this way:
<select id="listen" onchange="changeVehicleCondition(); document.getElementById('focus').focus()">...</select>
<input id="focus" />
Lets say your form panel is defined as variable "vehiclePnl" and the next field your wanted to focused is have name attribute "Mileage". Instead using your previous code
vehiclePnl.Mileage.focus();
Then you should use this code bellow
vehiclePnl.getForm().findField("Mileage").focus();
精彩评论