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

javascript for filling text box with value from dropdown list

New Here ,
Mar 02, 2017 Mar 02, 2017

I need to fill a textbox with a date depending on the selection from a dropdown list on the form. How do I do this? I'm not having much luck getting this thing figured out. Any help would be greatly appreciated.

Here's what I have now that isn't working. I'll also have an else if statement to compare the other selected items.
The Dropdownlist field is called Grant Number and the Textbox is labeled Text4

The different values for the grant dropdown list are TR15-100, TR16-100 or TR17-100

var e= document.getElementById("Tracking Group").text;

var f= document.getElementById("Text4");

if (e="TR15-100"){

f.text = "9/1/2015-3/31/2017";

}

TOPICS
PDF forms
6.4K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 02, 2017 Mar 02, 2017

OK. In that case you can use this code as the custom calculation script of Text4:

var e = this.getField("Tracking Group").valueAsString;

if (e=="TR15-100"){

    event.value = "9/1/2015-3/31/2017";

} else event.value = "";

View solution in original post

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
Community Expert ,
Mar 02, 2017 Mar 02, 2017

Are you talking about a PDF form or a web-page?

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 ,
Mar 02, 2017 Mar 02, 2017

This is a pdf form

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
Community Expert ,
Mar 02, 2017 Mar 02, 2017

OK. In that case you can use this code as the custom calculation script of Text4:

var e = this.getField("Tracking Group").valueAsString;

if (e=="TR15-100"){

    event.value = "9/1/2015-3/31/2017";

} else event.value = "";

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 ,
Mar 02, 2017 Mar 02, 2017
LATEST

That worked great. Thank you. Try67 greatly appreciated.

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
Community Expert ,
Mar 02, 2017 Mar 02, 2017

Your JavaScript code is for web 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