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

Fill text field based on entry of another

New Here ,
Jun 26, 2020 Jun 26, 2020

Copy link to clipboard

Copied

Using acrobat x pro

I'm using a bubble like sheet where on top is a box to enter 0-9 then underneath are bubbles(text fields. I am try to say if enter 1 in the box then bubble field 1 is black filled.  If 2 then bubble field 2 is black filled.... so on and on...  can anyone help?

TOPICS
Acrobat SDK and JavaScript

Views

419

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 , Jun 27, 2020 Jun 27, 2020

+++MODIFIED REPLY --fixed typos in the javascript example as observed by Bernd 

 

 

Hey Joseph,

 

I will use checkboxes for my example. You can use the script below to handle the fillColor  execution of the text fields.

 

I have to admit though, that my script below is as rookie as I can get my hands on javascript and is not very elegant or concise, but it works. 

 

 

 

 

var a = getField("A");
var b = getField("B");
var c = getField("C");
var d = getField("D");
var e = getField("E");
var f = getField("F");
...

Votes

Translate

Translate
Community Expert ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

+++MODIFIED REPLY --fixed typos in the javascript example as observed by Bernd 

 

 

Hey Joseph,

 

I will use checkboxes for my example. You can use the script below to handle the fillColor  execution of the text fields.

 

I have to admit though, that my script below is as rookie as I can get my hands on javascript and is not very elegant or concise, but it works. 

 

 

 

 

var a = getField("A");
var b = getField("B");
var c = getField("C");
var d = getField("D");
var e = getField("E");
var f = getField("F");
var g = getField("G");
var h = getField("H");
var i = getField("I");


if (event.value !=="") {

if (event.value =="1") {a.checkThisBox(0,true); a.fillColor = color.black;}
else if (event.value !="1") {a.checkThisBox(0,false); a.fillColor = color.white;}

if (event.value =="2") {b.checkThisBox(0,true); b.fillColor = color.black;}
else if (event.value !="2") {b.checkThisBox(0,false); b.fillColor = color.white;}

if (event.value =="3") {c.checkThisBox(0,true); c.fillColor = color.black;}
else if (event.value !="3") {c.checkThisBox(0,false); c.fillColor = color.white;}

if (event.value =="4") {d.checkThisBox(0,true); d.fillColor = color.black;}
else if (event.value !="4") {d.checkThisBox(0,false); d.fillColor = color.white;}

if (event.value =="5") {e.checkThisBox(0,true); e.fillColor = color.black;}
else if (event.value !="5") {e.checkThisBox(0,false); e.fillColor = color.white;}

if (event.value =="6") {f.checkThisBox(0,true); f.fillColor = color.black;}
else if (event.value !="6") {f.checkThisBox(0,false); f.fillColor = color.white;}

if (event.value =="7") {g.checkThisBox(0,true); g.fillColor = color.black;}
else if (event.value !="7") {g.checkThisBox(0,false); g.fillColor = color.white;}

if (event.value =="8") {h.checkThisBox(0,true); h.fillColor = color.black;}
else if (event.value !="8") {h.checkThisBox(0,false); h.fillColor = color.white;}

if (event.value =="9") {i.checkThisBox(0,true); i.fillColor = color.black;}
else if (event.value !="9") {i.checkThisBox(0,false); i.fillColor = color.white;}

} else {

if (event.value =="") {

a.checkThisBox(0,false); a.fillColor = color.white;
b.checkThisBox(0,false); b.fillColor = color.white;
c.checkThisBox(0,false); c.fillColor = color.white;
d.checkThisBox(0,false); d.fillColor = color.white;
e.checkThisBox(0,false); e.fillColor = color.white;
f.checkThisBox(0,false); f.fillColor = color.white;
g.checkThisBox(0,false); g.fillColor = color.white;
h.checkThisBox(0,false); h.fillColor = color.white;
i.checkThisBox(0,false); i.fillColor = color.white;

  }

}

 

 

 

 

Also make sure that in the text field that your users ill input a number is formatted as number with 0 decimal spaces and limit to one charachter only. This will avoid user typos.

 

NOTE: I 've also made this work before in my PDFs using a mix of combobox and checkboxes, where the user selects an item from the dropdown menu . As you can see there is a variety of ways that you can achieve this using javascript.

 

See slides below:

 

textfield.png

 

 

 

textfield1.png

 

 

  

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 ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

Why so many

if (event.value !="1") 

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 ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

That is  a typo , thanks for spotting that I will fix my reply

 

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

Copy link to clipboard

Copied

Ok where do I put what? Forgive my ignorance I'm new and learning 

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

Copy link to clipboard

Copied

LATEST

Hi Joseph,

 

You can copy the script that I posted above for you and paste it as custom calcultaion scriptin the text field that the users will be entering the numbers.

 

See slide:

 

customcalc.png

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