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

adding a string based on established value. Removing string on event change

Explorer ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

I am working on a combobox that is one of several inputs that populate a one field. I use the SetFieldValues to achieve this.

if (level.value>=3){
SetFieldValues(event.value)
function SetFieldValues(cName){
if (this.getField("Other Proficiencies").value !=="")
{this.getField("Other Proficiencies").value= this.getField("Other Proficiencies").value += "," + LangProf[cName].prof;}
else
{this.getField("Other Proficiencies").value=LangProf[cName].prof;}}}

My first issue is that I have to recommit the combobox value to trigger the function. I am looking for a way to have it read the value already present and add accordingly without overwritting the target field.  

My second issue is when the value changes, the previous string remains in the field. I don't mind deleting it but if there is a way to do it automatically, it would have multiple applications for my project.

Thanks for reading and also for any help!

TOPICS
Create PDFs , Edit and convert PDFs , JavaScript , PDF forms

Views

549

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

correct answers 1 Correct answer

Community Expert , Mar 03, 2021 Mar 03, 2021

Use event.change, and check that event.willCommit equals false first.

Votes

Translate

Translate
Community Expert ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

Where did you place the code?

Did you make sure to tick the option to commit the selected value of the drop-down field immediately?

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
Explorer ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

I have it placed on the combobox under custom keystroke and the value is commited immediately. I just realized if the correct user value is present, and then I switch to any new value, that is when the string will pop up. It seems to ignore the current value and waits for the next value to be selected.   

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
Community Expert ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

Use event.change, and check that event.willCommit equals false first.

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
Explorer ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

Thank you for the advice! This sounds like the way forward. I will do my reading to see what I can do. 

Is there a way to remove the string after the fact? I was thinking I could just subtract LangProf[cName].prof but that sounds like it would just cancel out rather than undo.

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
Community Expert ,
Mar 03, 2021 Mar 03, 2021

Copy link to clipboard

Copied

You can simply delete the contents of the field.

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
Explorer ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

I have tried to implement this advice but cannot seem to wrap my head around it. Considering the code I provided in the original post, how would you amend it with !event.willCommit and event.rc? I don't mean to waste any of your time but the resources I find online are beyond my ken. Thank you for the help you have already given.

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
Community Expert ,
Mar 11, 2021 Mar 11, 2021

Copy link to clipboard

Copied

Just move the code to the Validation event, it's easier...

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
Explorer ,
Mar 12, 2021 Mar 12, 2021

Copy link to clipboard

Copied

LATEST

I will try this. Thank you again for the response.

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