Print Page | Close Window

Conditional Format

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1270
Printed Date: 17 Sep 2019 at 10:34pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Conditional Format
Posted By: alton.carroll05
Subject: Conditional Format
Date Posted: 19 Aug 2014 at 6:04pm
 am brand new to Java, so I this may be a simple fix and I just can't figure it out.

I am trying to change the fill color of a text box based on the selection of a radio button.

 

I have 4 radio button choices

cent.grn

cent.amb

cent.red

cent.blk

 

and a text box that I would like to change fill color

 

tf.assmnt.stat

 

So...

 

if cent.grn is selected tf.assmnt.stat fill color = Green

if cent.amb is selected tf.assmnt.stat fill color = Orange

if cent.red is selected tf.assmnt.stat fill color = Red

if cent.blk is selected tf.assmnt.stat fill color = Black

 

Thanks in advance

Al




Replies:
Posted By: gkaiseril
Date Posted: 19 Aug 2014 at 6:54pm
Acrobat forms use a variation of JavaScript and not the computer programing language Java.

Are the radio buttons in an exclusionary group with unique export values? 

Then test the value of the group. When there is no selection the value is the string "Off".
 
Assuming the optional value for the selected button is the color name.
 
// the custom calculation script for the text field tf.assmnt.stat;
// make desion on value of radio button group;
switch(this.getField("cent").value.toLowerCase()) {
case "black" :
event.target.fillColor = color.black;
break;
case "green" :
event.target.fillColor = color.green;
break;
case "orange" :
event.target.fillColor = ["CMYK", 0, .62, 1, 0];
break;
case "red" :
event.target.fillColor = color.red;
break;
default:
// all other seelctions;
event.target.fillColor = color.transparent;
break;
} // end switch radio button;

 
 


Posted By: aandi
Date Posted: 19 Aug 2014 at 7:00pm
Not an answer but a note. It isn't Java. It's JavaScript. This matters a lot because if you search the web for information on Java, you'll get a load of stuff that doesn't help but looks as if it might, because Java exists, looks similar, and is actually very different....


Posted By: alton.carroll05
Date Posted: 19 Aug 2014 at 9:39pm
Thanks alot....and the semantics makes since that my web searches gives me content that is close, but still confusing.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net