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

Adding Numbering to Text Box

Avatar

Level 3

Hi!

I have a text box that shows a default text as follows:

1. Some Text

2. Some Text

However, I want be able to write a scrip that will increment the number by one each time the user hits enter. Just like it works on a Text editor such as MS Word.

Thank you!!!

3 Replies

Avatar

Level 6

Not sure I follow...

Are you trying to add a new textfield at each button click... for example:

3. Some text

4. Some text

...

Are you trying to increment the number & field?

Avatar

Level 3

Hi,

Just the number. I already have a default text there as it never changes so the user of the form would always have to start at "3". So, with every time the user hits the return key, the following number gets added, and it'd be awesome if deleting a number would make the rest of the number to adjust accordantly. Just like you would see in MS Word.

1. Some text

2. Some text

3.

4.

5.

THANK YOU!!!!

Avatar

Level 6

I'm not sure how your form is set up, but chances are you'll need to save the form as a dynamic PDF, and also have your content Flowed top-to-bottom within a subform.

One of the easiest ways to acheive what you're looking for is to create a 2 column/ 1 row table and include an Add button for users to add new rows (comparable to them pressing Return). The tables single row (renamed to "Row" in this example) should have Binding set (e.g.select "Repeat Row for Each Data Item", and also set "Min Count" to 1 and the "Inital Count" to 2)

In column 1/row 1 cell, add this "javascript" script on the layout:ready event:

this.rawValue = this.parent.index + 1;

//the script above will return the subform instance count. The first number will be 1. each button click will add a new row to the table and also increase the # in the first cell of each new row by 1.  the second cell in the table is where the user enters data.

In column 2/row 1 cell, add this "FormCalc" script also on layout:ready event:

if (Cell1 == 1)

then

$ = "Default test one" //edit to include default text

$.access = "protected"

elseif (Cell1 == 2)

then

$ = "default text two" //edit to include default text

$.access = "protected"

endif

//the script above will add the default text to both rows (i.e. the auto-created rows since you set the Row inital count to 2), as well as set this the default text in both rows to "protected" so the user can't change the values.

The add button at the bototm of the table should have this script:

Table1._Row.addInstance(); //the names could be differnt based on your table and row naming, and/or form layout

So, when the user clicks the button they will get a new row starting at 3, and a blank field to the right of the row number to enter text.

I hope this helps.  I don't know your level of scripting, so let me know if anything is confusing.