Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using Javascript for sequence number generation

SoofiNov 25 2014 — edited Nov 25 2014

Hi All,

I am having some problem with Javascript. I need to generate sequence number based on document number generated

i.e., for doc. no 5091 my tabular form should generate sequence number 1,2,3... when i hit Add row button.

For which I opt for going to Javascript. So I put a button called TEST as you can see in the below pic.apex.png

Now I created a dynamic action "test_da" for button testapex2.png

My True Action is...

apex3.png

The above code i used is

{

apex.widget.tabular.addRow();

}

var last_rownum = $('input[name="f04"]').closest('tbody tr:nth-last-child(1)').children('td').children('input[name="f04"]').val();

var next_rownum = 0;

if(last_rownum == ''){last_rownum = 0};

next_rownum = Number(last_rownum) + 1;

if(last_rownum == ''){last_rownum = 0};

$('input[name="f04"]').closest('tbody tr:nth-last-child(1)').children('td').children('input[name="f04"]').val(next_rownum);

The above code inserts a new row but the sequence number is not incremented. (See my first picture)

I also need to check that current row is saved before adding next row.

Any Help greatly appreciated.

Regards,

Soofi

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 23 2014
Added on Nov 25 2014
2 comments
1,340 views