views:

29

answers:

2

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);
        }
    }

Edit: focus() doesn't work for me, because I tried this already:

vehiclePnl.Mileage.focus();

with no luck..

A: 

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" />
cjavapro
When I use focus it places the "focus" one the other field, because when I hit 'tab' it actually goes to the field AFTER the next field, however, it stays highlighted on the current field, and when you type right away the characters still go into the field you were on, so it's not working. ExtJs might make things kind of weird...
Scott
A: 

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.

Scott