4 Replies Latest reply on Sep 7, 2011 12:12 PM by Jerry62712

    javascript in form - copying a value

    Jerry62712 Level 1

      I have a form with one field that I want to have a different field's value.  This is done in a claculate event (the only event with any scripts on this field).

       

      I have an "alert" popup that shows the proper value is being assigned to the field, but when the form displays, numeric "1" comes up instead of the expected numeric "60".

       

      1) is there any way to check that this field isn't being changed somewhere else?  There are 27 pages in this form and a lot of fields on each so I don't want to have to go field by field.

      2) what event or thing happens after the calculate event (last line is a popup and shows the right value) and the display of the form?

      3) when I'm in the event, do I have to qualify the other fields on the form?

        • 1. Re: javascript in form - copying a value
          pguerett Level 6

          The easist way to do this is to make sure the fields have the same name and that the binding is set to global.

           

          To answer your questions ...if that is the only script in your form then it is not coming fom somewhere else.

          Yes you will have to qualify fields in other locations than where you are calling your script form.

           

          Paul

          • 2. Re: javascript in form - copying a value
            Jerry62712 Level 1

            There may be many scripts within the 27 pages of this PDF.  On that specific field (page 3, subform2, coreHours10), there is only one event, a calculate one.

             

            Here is that event-script:

            RSP.Page3.subform_part2Calc.CoreHours10::calculate - (JavaScript, client)
            // TANF1087 - J. Davidson 09/01/2011
            //    Category 06 v 04 calculating coreHours10 (no change for "04" - single parent)
            //    1) if category 04 don't change processing at all
            //    2) if category 06, hide "CU6" question
            //    3) if category 06, use divide9 as coreHours10 value
            //    4) if category 06, hide "CU6" verbage after coreHours10 field (3 text fields)

            var cat = "";
            if (RSP.Page3.caseNumber.rawValue != null)
            {
                cat = RSP.Page3.caseNumber.rawValue;
                cat = cat.substring(0,2);
               
            }
            else
            {
                cat = "04";                                        // default to 04 if null
            }

            // Testing - SEE BELOW QUOTE
            divide9.rawValue = 60;

            // original processing
            // CU6 = Yes
            if (yesNoRadioButtonsList.yesButton.rawValue == 1)   
                if (divide9.rawValue > 20)
                {                                     
                    coreHours10.rawValue = 20;
                }
                else
                {
                    coreHours10.rawValue = divide9.rawValue;
                }

            // CU6 = No
            if (yesNoRadioButtonsList.noButton.rawValue == 2)   
                if (divide9.rawValue > 30)
                {                                     
                    coreHours10.rawValue = 30;
                }
                else
                {
                    coreHours10.rawValue = divide9.rawValue;
                }

            // override "04" processing if "06"
            if (cat == "06")
            {   
                cat04Txt.presence = "invisible";
                yesNoRadioButtonsList.presence = "invisible";
                hoursTxt.presence = "invisible";
                aTxt.presence = "invisible";
                bTxt.presence = "invisible";

                if (divide9.rawValue != null)
                {
                    this.rawValue = divide9.rawValue;
                }
            }   
            // Testing only
            app.alert("**Testing - outside of 'if 06' code. Final core is: " + this.rawValue); - SEE BELOW QUOTE

            Comment #1: I force a value because the data is too hard to manipulate.

            Comment #2: this alert box displays expected "60"

             

            The original working version only included the stuff between "//CU6" and "// override" below it.  I don't understand some of that, specifically the "else" on the radiobuttons, but I didn't write it and once I get my part (category 06) done, I'll visit that code.

             

            When the form displays, a "1" is seen in CoreHours10 and not the expected "60".  Something must be changing the value of the field between this calculate event and the alert box and the final display to the user.

            • 3. Re: javascript in form - copying a value
              pguerett Level 6

              I woudl need to see the form in action ...can you post it here or send it to LiveCycle8@gmail.com

               

              Paul

              • 4. Re: javascript in form - copying a value
                Jerry62712 Level 1

                I don't think they will allow it, but I will ask.  I know I can't give the data even if I could think of an easy way to transport a database system.