Expand my Community achievements bar.

separate string upto comma(,)

Avatar

Level 2

dataroot.Transmittal_pdf.Table6.Row5.Recipient_Name::change - (JavaScript, client)

var rec_list = this.boundItem(xfa.event.newText).slice(0,this.boundItem(xfa.event.newText).insexOf(","))  ------ is this correct to get the string upto "," (comma)

xfa.host.messageBox(rec_list);

This code not working for me. somebody please help me

with regards

prasad

4 Replies

Avatar

Level 5

Hi,

You have a spelling mistake "insexOf" should be "indexOf". Once that is changed it should work.

Hope that helps

Malcolm

Avatar

Level 2

Malcom 

ya. thank you. now it is worked fine. i have another problem. 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 filelds . thease values are not constant.

var rec_list = dataroot.Transmittal_pdf.txt_ref.rawValue.slice(0,dataroot.Transmittal_pdf.txt_ref.rawValue.indexOf("/"));  this line separates 456

but how to get D.9.1 out of the above text. please help me.

Avatar

Former Community Member

Hi Prasad,

  if your D.9.1 always comes after second "/",

then this stmt might help you

var fromIndex = dataroot.Transmittal_pdf.txt_ref.rawValue.indexOf("/"); //returns the first index value after your number 456 i.e., 4.

var rec_list2 = dataroot.Transmittal_pdf.txt_ref.rawValue.slice(fromIndex + 1,dataroot.Transmittal_pdf.txt_ref.rawValue.indexOf("/"));  this gives the string between the first "/" and the second one i.e.,D.9.1.

Hope this works good for you.

kc


Avatar

Level 2

kc,

I tried in the same way as you told .but rec_list2 message list not displaying .?.

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

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

xfa.host.messageBox(rec_list);

xfa.host.messageBox(rec_list2);

with regards

prasad

var rec_list = dataroot.Transmittal_pdf.txt_ref.rawValue.slice(0,fromIndex);