Expand my Community achievements bar.

SOLVED

Trying to automatically populate info entered in one section of a form into another

Avatar

Level 2

I am creating a form in which I need information that is entered or selected (either from a drop down or  a radio button selection) in the top half of the form to be populated into a section at the bottom of the form. I don't want the info at the bottom of the form to be editable - I just want to have it show up as text.

So far I have been unable to get any of the info to populate automatically at the bottom. I thought by copying the text fields from the top of the form and pasting them at the bottom, keeping the Binding Name the same, it  would work, but so far it doesn't.  And I have no idea how to copy the value of the drop-down or radio button to another place on the form.

Thanks in advance for any help.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

In your menu click

window

    -------script editor

it may not initially sow up but at the top of your screen you will see a tab with a button pointing down clicking it will expand the script section

You may have to drag it to a larger size to see more than one line

the script they are refering to needs to go on the calculate event

at the top of the script window is a field that says show

click the dropdown button and select the calculate event it should be about the 4th one down

example

under    form1.pg1.TextField1::calculate - (FormCalc, client)

$.rawValue = DropDownList1.rawValue

View solution in original post

20 Replies

Avatar

Level 10

Hi,

You can use floating fields for this task.

Just create a text object at the bottom of your form and double-click it to enter some text.

Then right-click the field and select floating field from the context menu.

Designer inserts a hidden text field object in the hierarchy and you'll also see its {name} at the text cursors position in the text object.

Rename it to that fields name you want to populate the value from.

Avatar

Level 3

Use below script on calculate event of the text field to be auto populated:

this.rawValue=DropDownList1.rawValue;

Regards,

Varun

Avatar

Level 2

Radzmar,

Sorry, but your instructions are not clear enough. I have tried this but it did not work, so I am sure that I am missing something. First of all, to be clear, you are talking about inserting a Text object, not a Text Field object, correct?

I insert a Text object and then right click to select Floating Field (or you can also select it from the Insert menu). It then adds text into the box that says "{TextField}". I cannot type directly within the brackets. So I am guessing that you are supposed to copy the name of the source field into someplace else. But where? Do I copy it into the Name field on the Binding Tab of the Object pallette? Or does it go someplace else? And what do I use for the source value? Am I copying the Name field on the Binding Tab from the source Text Field object?

Please give me more specific step by step instructions.

Thanks very much in advance.

Avatar

Level 2

vNohria,

I appreciate the script line that you sent, but i have no idea where I can insert the script. I can't figure out how you get to a script editor. Also what type of object should I use? Can I use a Text field to display the value of a drop-down? And what about a radio button?

Finally, in your script, you refer to "DropDown1". Am I supposed to use that exact name or should I use the name of the dropdown field that is the source?

Thanks

Avatar

Correct answer by
Former Community Member

In your menu click

window

    -------script editor

it may not initially sow up but at the top of your screen you will see a tab with a button pointing down clicking it will expand the script section

You may have to drag it to a larger size to see more than one line

the script they are refering to needs to go on the calculate event

at the top of the script window is a field that says show

click the dropdown button and select the calculate event it should be about the 4th one down

example

under    form1.pg1.TextField1::calculate - (FormCalc, client)

$.rawValue = DropDownList1.rawValue

Avatar

Level 2

mobiusconstruct,

Thanks, that worked perfectly for the drop down.

Now, do you know any way to grab the value of a radio button option and place it into a text box. For example, I have a group of Radio buttons. The group name is ExceptionHold. Say for example, there are three radio buttons labeled "One", "Two", and "Three" (They show up with those labels in the "Item" menu on the Field tab of the Object Pallete - on the Binding tab, those items show up with a numeric value associated with each item).

So at the bottom of the form. I need to have some  text that says something like "you have selected the ? option" (where the item label from the dropdown goes where the "? is).

Thanks once again

Avatar

Former Community Member

place this code on the calculate event for the text box  (its in FormCalc)

if ( pg1.rad1.rawValue == 1 )

then

$.rawValue = "10.05"

elseif ( pg1.rad1.rawValue == 2 )

then

$.rawValue = "11.13"

elseif ( pg1.rad1.rawValue == 3 )

then

$.rawValue = "12.00"

else

$.rawValue = 0

endif

Avatar

Level 2

A little further info. I was able to place a Text Field object and use the script to grab the VALUE of the radio button that was selected. But that is a numeric value only. What I need to do is to insert the label of the radio button into that text field (the Item column instead of the Value column). Is there are way to do this? Perhaps a different variable besides "rawValue"?

Thanks

Avatar

Former Community Member

I to am working on a similar form but Im trying to use the right hand pane to dynamically update using the master page

Works like a charm except for one little problem It only updates pg1

I precreated all my fields on the master page and set them to instance(0) then create them as I need them

Im still hoping for an answer to my question here today

Avatar

Level 2

I was just posiing my last reply as you were posting your last reply. I think I understand the script. In your example above, are the values in quote "10.05", "11.13", etc. suppose dto be the exact thing I copy or should they be my text from the labels?

Also, should I be using "pg1.rad1", or should I be substituting the name of the radio button group?

Avatar

Former Community Member

if ( pg1.rad1.rawValue == 1 ) /// this is to be replaced with your radio buttons name

then

$.rawValue = "10.05"  ////Replace what is in the quotes with what you need displayed

elseif ( pg1.rad1.rawValue == 2 ) ///the 1,2 or 3 is the default radio button values easiest to reference with a script I would leave them be

then

$.rawValue = "11.13"

elseif ( pg1.rad1.rawValue == 3 )

then

$.rawValue = "12.00"

else

$.rawValue = 0

endif

here is how I did it

I create a radio button group

on their properties i click the layout tab and

caption

----position

--------none

instead i use a text field to add the text i want

this makes programming base on their raw values simpler

Avatar

Level 2

Unfortunately, it is still not working for me. Following is the code I inserted:

 

form1.#subform[0].TextField2::calculate - (JavaScript, client)

 

If ( ExceptionHold.rawValue == 1 )

then

$.rawValue="New Account"

elseif ( ExceptionHold.rawValue == 2 )

then

$.rawValue="New Account Next Day Item Exceeds $5000"

endif

There are actually nine radio buttons but I figured I would test with two of them before creating the whole thing. I assumed this would work as long as I selected one of the first two buttons when viewing teh form.

I notice in looking at the script for the dropdown (which I previously created based on your help) that it says:

$.rawValue=DepositMade.rawValue;

this.rawValue=DropDownList1.rawValue;

I only entered the first line of code, not the second one. I assume that Adobe created that second line automatically. I also did not type in the semicolons and again assume that Adobe inserted them. Since I don't see this in the If Then script for the radio buttons, that also leads me to believe I am missing something. Any ideas?

Thanks

Avatar

Former Community Member

The examples I gave you are formcalc not javascript

make sure you select that or change it acfordingly

for example under javascript

$.rawvalue

would be

this.rawValue

etc

Avatar

Level 2

THAT WORKED. Excellent, thank you. You were a tremedous help

Avatar

Level 2

mobius,

I've run into one more issue. One of the fields I am trying to auto populate is a date. The source field is set up with a data pattern in the following format on all four tabs in thePattern window: date{MM/DD/YYYY}

But in the autopopulated field, the data shows up as yyyy-mm-dd. I assume this is related to the raw value and I have to convert the display version using script, but am uncertain how to do this. I have looked up some simple functions that will covert the data format but am not sure how to tie them to the incoming data. Any suggestions?

Avatar

Former Community Member

you could use copy the field and use the bind properties or

in your script

.formattedValue

Avatar

Level 2

Thanks. The .formatted value did the trick

Avatar

Level 2

Hi mobius,

Ok. I thought I had everything solved, but then I realized that I needed a nested conditional statement, because I have a second set of two radio buttons that apply if you pick a specific button within the first set of radio buttons. (The second set of buttons is in its own group). I can't get this to work.

If I try it in formcalc, I get a syntax error. If I leave in the curly braces that you would normally have in a javascript conditional statement, I get a syntax error on the line with the first curley brace. And if I take them out, I get a syntax error on the line where the nested if statement occurs. (And of course, once you have a nested if in javascript, you really need to use the curley braces).

And if I try it in javascript, I don't get any syntax errors, BUT I  still can't get the value to display, even when I change all occurrences of  $.rawvalue to this.rawvalue.

Is there something I am missing if I need to do it in javascript? I should mention that I also tried removing the "then" statement, which I know that you don't need in javascript, but it still didn't work.

Here is an abbreviated version of the script (I have 9 radio buttons at the top level so I have left out many of the elseif statements):

form1.#subform[0].TextField2::calculate - (FormCalc, client)

If (ExceptionHold.rawValue==0)  {

then

$.rawValue="Standard"

} elseif (ExceptionHold.rawValue==1) {

then

$.rawValue="New Account"

} elseif (ExceptionHold.rawValue==7) {

                if (Date.rawValue==0) {

                then

                $.rawValue="Collectability date Not Specified"

                } elseif (Date.rawValue==1) {

                then

                $.rawvalue="Stale Dated"

                } else {

                $.rawValue="Post Dated"

                }

} else  {

$.rawValue="Communications/Computer Equipment Offline"

}

endif

Avatar

Level 2

Mobius,

I figured out how to solve my delimma. Instead of using a nested if statement, I used the AND operator to combine the two sets of radio buttons. So I changed it to

 

elseif

(ExceptionHold.rawValue==7 and Date.rawValue==0)

then

$.rawValue="Collectability date Not Specified"

etc.

But I still don't understand why I can get it to display the values when using $.rawvalue in Formcalc, but when I try this.rawvalue in javascript, nothing displays.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----