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

Improving a script to assign form field values to a JS object to be added to another

Engaged ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

I have a portion of a script created to assign text form field values to a JS object to be added to another. While the script performs as anticipated, I can't help but think that there exists a better and shorter JS to accomplish the same task. For clarification, the form field names used to provide property values for the object to be added are prefaced with inf. whereas the value for the object name too be added gets assigned from a combo drop down field that serves as the event.value in the script. The portion of the script I am interested in refining is as follows:

 

 f1=getField("inf.lastUpdate");f2=getField("inf.website");f3=getField("inf.userID");f4=getField("inf.password");f5=getField("inf.primaryCC");f6=getField("inf.secondaryCC");f7=getField("inf.primaryBank");f8=getField("inf.secondaryBank");f9=getField("inf.sq1");f10=getField("inf.sa1");f11=getField("inf.sq2");f12=getField("inf.sa2");f13=getField("inf.notes1");f14=getField("inf.notes2");
oVendors[event.value]={lastUpdate:f1.value,website:f2.value,userID:f3.value,password:f4.value,primaryCC:f5.value,secondaryCC:f6.value,primaryBank:f7.value,secondaryBank:f8.value,sq1:f9.value,sa1:f10.value,sq2:f11.value,sa2:f12.value,notes1:f13.value,notes2:f14.value};

 

Given the names of the form fields, I don't see how I can shorten the script by using a loop but then again I may be missing something. Any suggestions regarding this subject matter are most appreciated. Thank you ahead of time.
   

TOPICS
How to , JavaScript , PDF forms

Views

214

Translate

Translate

Report

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
Engaged ,
Dec 20, 2022 Dec 20, 2022

Copy link to clipboard

Copied

LATEST

Resolved. No need to answer.

Votes

Translate

Translate

Report

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