Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Capturing First word from a textbox

Avatar

Level 1

Okay, small issue, I can't figure out how to grab the first word from several in a text box. Here is the code that captures the full line:

var LSTN = "LSTN"+xfa.form.OUTSTCHK12.FormPage1.Subform1.PayeeLastName.rawValue;

If someone could please help I would be very greatful.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Well now that you know ho to get the word it is simply a case of assigning it to another field. Assuming the other field is called OtherField you would use a command like this:

OtherField.rawValue = words[0]

Paul

View solution in original post

4 Replies

Avatar

Level 10

You can use javascript functions for that. Assuming your field that holds the sentence is PayeeLastName then you can do something like this:

     // Get value into a string

     var message = PayeeLastName.rawValue;

     //Use the split command to break up the string on the space char and place into an array called words

     var words = message.split(" ");

     //now the words array holds all of the words in the string. It is a zero base array so to get the 1st word

     app.alert("The first word is: " + words[0]);

Hope that helps

Paul

Avatar

Level 1

Your answer was helpful but I believe I phrased my question wrong, is there a way to grab just the first word and have it fill a different box instead of having the app.alert for the word.

Thanks

PS: Would it be possible to only change part of the code that I pasted to grab the first word and continue to place it where it's set to do so?

Avatar

Correct answer by
Level 10

Well now that you know ho to get the word it is simply a case of assigning it to another field. Assuming the other field is called OtherField you would use a command like this:

OtherField.rawValue = words[0]

Paul

Avatar

Level 1

Thank you for helping me out, it is greatly appreciated.