Expand my Community achievements bar.

problem with string.indexOf("/") function

Avatar

Level 2

I have text field value is 456/D.9.1/08/2011. i want to combine 456 - D.9.1 and i want to pass it to other fileld . The values between "/" 's are ot constant.

to acess the first characters in the text string i used

var fromIndex = dataroot.Transmittal_pdf.txt_ref.rawValue.indexOf("/");

var rec_list = dataroot.Transmittal_pdf.txt_ref.rawValue.slice(0,fromIndex);// returns the first index value after your number 456 this one working fine.

var rec_list2 = dataroot.Transmittal_pdf.txt_ref.rawValue.slice(fromIndex + 1,dataroot.Transmittal_pdf.txt_ref.rawValue.indexOf("/"));  // this value display problem? is this correct please check?

xfa.host.messageBox(rec_list); // this one dispaying

xfa.host.messageBox(rec_list2); // this one not dispaying why?

please help me.

with regards

prasad

2 Replies

Avatar

Level 10

Hi Prasad,

You will need to specifiy the start position in the second indexOf method, so try;

var rec_list2 = dataroot.Transmittal_pdf.txt_ref.rawValue.slice(fromIndex + 1,dataroot.Transmittal_pdf.txt_ref.rawValue.indexOf("/", fromIndex+1));

An alternative is;

var rec_list = dataroot.Transmittal_pdf.txt_ref.rawValue.split("/");
xfa.host.messageBox(rec_list[0])
xfa.host.messageBox(rec_list[1])

Regards

Bruce

Avatar

Level 2

thank you. It wirked out for me .