Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Spawning pages messes with my javascript!

New Here ,
Dec 08, 2016 Dec 08, 2016

Hi everyone,

I am self taught with javascript and adobe so please bear with me!

I have just finished making a massive form which on the second page there is a list of questions with yes or no for the answer and if they click Yes it spawns a template page which they can fill out, then go back and continue to next question. 

Problem is, on these templates I have javascripts that include the names of the fields.  When the page spawns, it changes the name of the fields and then the javascript doesnt work.  Is there anyway to overcome this problem? HELP PLEASE   Thanks so much in advance!

TOPICS
Acrobat SDK and JavaScript
516
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2016 Dec 08, 2016

Yes, there is a way to deal with this. If you post one of the scripts you're having trouble with, we should be able to suggest changes to it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 11, 2016 Dec 11, 2016

Thank you,

Example of my question is, I have a question with a Yes/No answer,  If they click no, the next questions under it are grey and read only so they know they don't have to answer those questions.  If they click yes I have it so they change to black and fillable so that they know they need to answer those questions.  the javascript I used for this is:

It's probably the wrong way to do it, but like I said I am self taught so its the best I could do haha

var myRad = getField("16");

if(myRad.value == "Yes")

{

getField("Total Floor area").textColor = color.black;

getField("m").textColor = color.black;

getField("m2").textColor = color.black;

getField("Height:").textColor = color.black;

getField("Percentage of overall floor space:").textColor = color.black;

getField("%1").textColor = color.black;

this.getField("Floor area").readonly = false;

this.getField("heights").readonly = false;

this.getField("% of floor").readonly = false;

}

Thanks in advance

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 11, 2016 Dec 11, 2016
LATEST

If you used the rename option when calling the spawn method, you have not accounted for the addition of the "P#.templateName." being prefixed onto the fields on thw spawned pages

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 09, 2016 Dec 09, 2016

A Lesson in Templates shows how fields are renamed during spawning pages with the 'bRename" parameter set to true.

The fields of the template are prefixed with "P[#}.[emplateName]."  If one uses the "event.target.name" property of the field name, the string value can be parsed to obtain the field's name split by the "." character. The first element of the array will be the "P[#}" value and the second element will be the template name. One then only needs to compute the prefix string which can be added to any field's template source name on the spawned page to obtain the full name of the field on the spawned page. I would create a document level function to generate this prefix string if the field has an altered name as part of the spaqning. If the field's name has not been altered then return a null stirng. This approach will allow one to workout the necessary scrpts on the template and easily add the prefix string if needed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines