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

Trying to have a Link or button URL change, based on value in a text field

New Here ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

Hello, 

 

I am currently trying to create a PDF of a schedule, where a user can select their desired program from a dropdown and the button will automatically have the corresponding link. 

 

I followed this tutorial to get the dropdown selection to effect a text field (successfully), but have no idea how to have the dropdown edit the link or button element, OR have the text field (based on the dropdown) effect the link/button. (I say link/button because I can use whichever works!)

 

Any assistance or links would be amazing, I've tried googling but no one else that I could find seems to want to do this. 

 

Thanks,

Sarah

TOPICS
Acrobat SDK and JavaScript

Views

489

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 , Jul 10, 2020 Jul 10, 2020

Ah OK, got it. Let's say the text field is called "Text1". You can then use this code as the MouseUp event of the button field:

 

var t1 = this.getField("Text1").valueAsString;

if (t1=="") app.alert("The field is empty.");

else app.launchURL(t1);

Votes

Translate

Translate
Community Expert ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

Please be a bit more specific. Do you want to use the value of the text field in the URL? So if the text field says "Text1" the URL that the button will launch will be "http://www.google.com/q/Text1", for example?

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
New Here ,
Jul 09, 2020 Jul 09, 2020

Copy link to clipboard

Copied

Sorry about that!
Basically, I want the text value appearing in the text field currently (its a URL) to be passed in. So, the value appearing as text in the text field is”www.google.com”, and I want that URL to be hyperlinked to a button.

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 ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

Ah OK, got it. Let's say the text field is called "Text1". You can then use this code as the MouseUp event of the button field:

 

var t1 = this.getField("Text1").valueAsString;

if (t1=="") app.alert("The field is empty.");

else app.launchURL(t1);

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
New Here ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

You are a LIFE SAVER. 

Thank you so much! This worked perfectly. Is there a way to give kudos on here? 

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 ,
Jul 10, 2020 Jul 10, 2020

Copy link to clipboard

Copied

LATEST

You're welcome!

 

Marking the answer as correct (and maybe liking it) is enough.

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