# Dashboard Template next field on enter

**URL:** <https://discourse.nodered.org/t/dashboard-template-next-field-on-enter/39425>\
**Category:** Dashboard\
**Created:** [20 January 2021 10:20 UTC](https://discourse.nodered.org/t/dashboard-template-next-field-on-enter/39425 "2021-01-20T10:20:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [20 January 2021 11:53 UTC](https://discourse.nodered.org/t/dashboard-template-next-field-on-enter/39425/2 "2021-01-20T11:53:17Z")

</div>

Hi James, try this...

```auto
<script>
(function(scope) {
    console.log("in scope (this log entry helps us finding the code in devtools :)");
    document.querySelectorAll('#myInputTable1 input').forEach( el => {
        el.addEventListener('keydown', e => {
            if(e.keyCode === 13) {
                let nextCol = el.parentNode.nextElementSibling;
                if (!nextCol) return;
                let nextEl = nextCol.firstElementChild;
                if (!nextEl) return;
                if(nextEl.nodeName === 'INPUT') {
                    nextEl.focus();
                } else if(nextEl.nodeName === 'BUTTON') {
                    $(nextEl).click();//operate the button
                    $('#myInputTable1 input[ng-model]').val('');//clear the fields
                    $('#myInputTable1 input[ng-model="message.customerID"]').focus();//go back to 1st input
                }
            }
        })
    })
})(scope);
</script>

<table cellspacing="0" cellpadding="0" id="myInputTable1">

    <tr >
        <td>Customer ID</td>
        <td>Customer</td>
        <td>Model</td>
        <td>IMEI</td>
        <td>ICCID</td>
        <td>Add</td>
    </tr>
   <tr>
        <td><input type="text" ng-model="message.customerID" ></td>
        <td><input type="text" ng-model="message.customer"></td>
        <td><input type="text" ng-model="message.model"></td>
        <td><input type="text" ng-model="message.imei"></td>
        <td><input type="text" ng-model="message.iccid"></td>
        <td>
            <md-button ng-click="send({payload: {
                 customerID: message.customerID,
                 customer : message.customer,
                 model : message.model,
                 imei : message.imei,
                 iccid : message.iccid,
                 action : 'add' }})" > Add
            </md-button></td>
    </tr>
</table>

```

connect a debug node to the output of the ui\_template

---

_[View the full topic](https://discourse.nodered.org/t/dashboard-template-next-field-on-enter/39425)._
