Saddam Meshaal Saddam Meshaal - 3 months ago 26
jQuery Question

Oracle APEX | How to Focus Last Added Row In Tabular Form

I want the bellow code to add new row to the

Tabular Form
and move focus to the first cell on the (added row)
for example (#f02_0003)
:

apex.widget.tabular.addRow();
for (i=1;i<100;i=i+1)
// to loop all existing row in order to get the new added row id
{
if( $('#f02_'+('000'+i).slice(-4)).length()>0 )
// to check whether the row with looped id exists or not
{
continue;
}
else
{
$('#f02_'+('000'+(i-1)).slice(-4)).focus();
// to focus the expected added row
break;
}
}


It add new row But Never focus any cell.

Help Please!..

Answer

remove the loop. Then add the following line(assuming that the name of the element under the first column is 'f02'):

$("[name='f02']").last().focus();