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

Checkbox value in Text Field

Explorer ,
Mar 24, 2021 Mar 24, 2021

Hi

 

I have 5 check Boxes named as Check Box1, Check Box2, Check Box3, Check Box4, Check Box5

& a TextField named as Score. I want when I check (Check Box1) a Value 5 appear in Score textfield.

& when i check Check Box2 value 10 appears in Score text field & so on.

 

Any help?

 

Thanks & Regards

Junaid Khalid

TOPICS
Create PDFs , JavaScript , PDF forms
6.7K
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
2 ACCEPTED SOLUTIONS
Community Expert ,
Mar 24, 2021 Mar 24, 2021

If you are gonna check only 1 you can use this code:

if(this.getField("Check Box1").valueAsString != "Off")
event.value = "5";
else if(this.getField("Check Box2").valueAsString != "Off")
event.value = "10";
else if(this.getField("Check Box3").valueAsString != "Off")
event.value = "15";
else if(this.getField("Check Box4").valueAsString != "Off")
event.value = "20";
else if(this.getField("Check Box5").valueAsString != "Off")
event.value = "25";
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 24, 2021 Mar 24, 2021
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 24, 2021 Mar 24, 2021

Every checkbox is worth 5?

If so then you can use this script as "Custom calculation script" of "Score" field:

var total = 0;
for ( var i=1; i<=5; i++){
if(this.getField("Check Box"+i).valueAsString != "Off")total++;}
if(total == 0)
event.value = "";
else
event.value = total*5;
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
Explorer ,
Mar 24, 2021 Mar 24, 2021

Thank You for reply

Check Box1 value is 5 Check Box2 Value is 10 Check Box 3 Value is 15, Check box export value is Yes, above mentioned code is not working in my form.

Thanks

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 24, 2021 Mar 24, 2021

I assumed you wanted to total checkboxes value in score field so disregard code above.

What happen if two or more of checkboxes are checked?

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

I will only check 1 Check Box at a time

or if you sugest then i will choose radio button option.

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 24, 2021 Mar 24, 2021

If you are gonna check only 1 you can use this code:

if(this.getField("Check Box1").valueAsString != "Off")
event.value = "5";
else if(this.getField("Check Box2").valueAsString != "Off")
event.value = "10";
else if(this.getField("Check Box3").valueAsString != "Off")
event.value = "15";
else if(this.getField("Check Box4").valueAsString != "Off")
event.value = "20";
else if(this.getField("Check Box5").valueAsString != "Off")
event.value = "25";
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
Explorer ,
Mar 24, 2021 Mar 24, 2021

Sorry Ms. Neha still script is not working can i share my remote access with you?

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 24, 2021 Mar 24, 2021

What exactly isn't working?

You can upload your file to site like google drive or similar and post link here.

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

https://drive.google.com/file/d/1ud6bRkn4iOk7wgffYZ9tRSCFRJ2uZlcy/view?usp=sharing

file uploaded to google drive.

When i place above script in Score Text field nothing happened.

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 24, 2021 Mar 24, 2021

You need to allow access in google drive, right click on your file and select get link and change it to anyone with the link.

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

Thank You Sooooooooooooooooooooooooo Much Ms. Nesa, I found my mistake i was putting that script in validation instead of custom calculation. You are very genious Ms. I am very gratefull to you. Sorry I wasted a lot of time. It's working like a charm. Sorry Again You are very kind & i hope in future you will again help me.

 

Thanks A Lot............

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

Can you please modify this script for Radio Button? I am using Radio Button (Group 1) Export value (Choice1) I tried in many ways by changing values in Export values or tried to change some values is in Javascript code but did not get any solution.

Thanks in advance....

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 24, 2021 Mar 24, 2021

Use like this:

if(this.getField("Group1").valueAsString == "Choice1")
event.value = "5";

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
Explorer ,
Apr 19, 2021 Apr 19, 2021

check.JPGexpand image

I want to check only one checked box, if any checkbox checked other automatically unchecked. How can I do this? 

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 ,
Apr 19, 2021 Apr 19, 2021

Give them same name, for example name all of them "Check" and give them different export values in checkbox properties under 'options' tab.

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
Explorer ,
Apr 19, 2021 Apr 19, 2021

When checked CheckBox1 text field get value 10, checked CheckBox2 text field get value 25, checked CheckBox3 text filed get 35, Checked CheckBox4 text filed get value 60, Checked CheckBox5 text filed get value 95,

Only checked one Checkbox, if try to Check multiple Checkbox, Previous checkbox automatically Unchecked,  

Only one checkbox value pass in Text Field, 

My PDF link hare: https://drive.google.com/file/d/1gEAe3u5L5e3ITK-s1oCtFmULve5SdTTY/view?usp=sharing 

How can I do this? Please help me.

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 24, 2021 Mar 24, 2021

Use check boxes with the same name and different export values.

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

Bro i have very little knowledge in Javascript and adobe fields my export value of check box is Yes, what value should be there according to script?

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 24, 2021 Mar 24, 2021

Did you put script in calculation or validation?

You can also do what Bernd said and name all 5 checkboxes to "Check Box" and give each different export value (5,10,15...etc) and then as custom calculation script of Score field use this:

if(this.getField("Check Box").value != "Off")
event.value = this.getField("Check Box").value;
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
Explorer ,
Mar 24, 2021 Mar 24, 2021

I am putting script in Validation, When i rename all check boxes to Check Box then when I tick 1st check box all other check boxes checked automatically.

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 24, 2021 Mar 24, 2021
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
Explorer ,
Apr 19, 2021 Apr 19, 2021

Thank you very much to give your valuable time, It's work.

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 24, 2021 Mar 24, 2021

You can use the export values 5, 10, 15, ...

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 ,
Feb 14, 2022 Feb 14, 2022

Hi Nesa, 

 

We´re trying total checkboxes value in score field but still not working. Any help?

 

we used: 

 

if(this.getField("box1").value != "Off")
event.value = this.getField("box1").value;
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