Checkbox value in Text Field

Explorer ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

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

Views

651

Likes

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 2 Correct Answers

Adobe Community Professional , 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 = "";

Likes

Translate

Translate
Adobe Community Professional , Mar 24, 2021 Mar 24, 2021

Likes

Translate

Translate
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

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;

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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?

Likes

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

Copy link to clipboard

Copied

I will only check 1 Check Box at a time

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

Likes

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

Copy link to clipboard

Copied

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 = "";

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

What exactly isn't working?

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

Likes

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

Copy link to clipboard

Copied

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.

Likes

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

Copy link to clipboard

Copied

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.

Likes

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

Copy link to clipboard

Copied

Likes

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

Copy link to clipboard

Copied

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............

Likes

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

Copy link to clipboard

Copied

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....

Likes

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

Copy link to clipboard

Copied

Use like this:

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

Likes

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

Copy link to clipboard

Copied

check.JPG

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

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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.

Likes

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

Copy link to clipboard

Copied

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

Likes

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

Copy link to clipboard

Copied

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?

Likes

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

Copy link to clipboard

Copied

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 = "";

Likes

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

Copy link to clipboard

Copied

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.

Likes

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

Copy link to clipboard

Copied

Likes

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

Copy link to clipboard

Copied

LATEST

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

Likes

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

Copy link to clipboard

Copied

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

Likes

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