Expand my Community achievements bar.

Color a field

Avatar

Level 2

Hello,

I am new to LiveCylce and I have a question.

I own a auto repair shop and have a vehicle inspection form that I use for vehicles that come into the shop. Each item on the form has three checkboxes labeled for the condition of the item.

I am trying to make a new inspection form and each item on the inspection form would have one rectangle next to it that I would be able to change color depending on the condition of the item "Red" for severe or safety issue "Yellow" for recommended & "Green" for acceptable.

I would like to have three buttons on the form that when pressed would change the color of the rectangle that I am on for each color labeled  Severe, Recommended & Acceptable. Or one button that could be pressed once for Red twice for yellow and three times for green. I just want to have one instance of this on the form so I don't have buttons all over the place.

I have attached a pdf of the old form so you can see what it consisted of.

Thanks in advance

48 Replies

Avatar

Level 10

Hi,

Attached is an example of a button that when clicked changes from white, to green, to amber, to red, and back to white. You could have a single button for each criteria.

The javascript is in the click event of the button.

Good luck,

Niall

Avatar

Level 2

Hello,

Looks great!!

I changed the script a bit to make the amber colored button yellow.

I would like all the text in the buttons to be black if I could.

I would like to have the button default as the Green or "Acceptable" color then Yellow "Recommended" then Red "Severe" then White

"Not Applicable" (this.caption.value.text ="N/A") then default back to the Green button. I am attaching the file.

Thanks in advance

P.S. Will I be able to fill this out in Acrobat Reader nd save if I want to?

Avatar

Level 10

Hi,

The font colour is straightforward, go to the Font tab and select the colour from the drop down.

In relation to the sequence of the button, I would recommend allow the button to revert to N/A (white), so that if the user starts to click a criteria, they can go back to N/A, otherwise they are caught in a loop.

Both are scripted.

In order to be able to save the form in Reader, you will need to "reader enable" the form. You can do this within the full version of Acrobat (standard in v9 or Professional in v8, lower). This is available from the Advanced menu. Note there are licence restrictions when you reader enable through Acrobat. A full reader enable through the full LC enterprise, which is €€€.

Hope that helps,

Niall

Avatar

Level 2

I really need the button to default to green with an "A" in it otherwise whoever uses the form will have to

click each button once to get to the green color which equals "Acceptable".

Most of the items on the form are usually acceptable so I thought the acceptable button should be the default. I guess I don't know enough about JavaScript to know why this would not work.

Thanks in advance

Avatar

Level 10

Sorry, I misunderstood you.

You can get script a form to get it to do almost anything you want.

In this revision the script for the button is the same, I jst chaged the starting point to green and "A" in the Object / Field tab.

Hope that helps,

Niall

Avatar

Level 2

Niall,

Can you change the color of the green button?

I changed the color in the script and the background of the button to 0,157,2 it would not change colors anymore. I don't know why that would happen, maybe I don't know enough about scripting or something but I thought you could change this in the code or the default color of the button. Seems like the code is very finicky about changes. Update...found out that the XML code "fill" tag color was different I changed it to 0,157,2 then the colors changed correctly, whew whoo!!

Can the text in the button be white for the red "S" state and the green "A"  state so if I print in black and white the letters can be seen? That was the reason for wanting to change the color of the green "A" button (plus it's the same color green as my logo now).

Once I get this all sussed out can I save it as a fragment?

I saw your document ChangingVisualObjectProperties.pdf cool stuff the thing that intrigued me was the checkbox for "Expand to fit the width of the value". Can this be done to all dropdown lists in my form in case the user inputted text that overflows the entry field?

Plus I want to thank you for all your help thus far!!

Cheers

John 

P.S. I sent an attachment of what I have so far.

Avatar

Level 10

Hi,

You don't (generally) need to go into the XML Source to tweak scripts or objects.  It can be useful sometimes, but generally you can deal with most requirements in Design View. For example, changing the defualt green in Design View.

You will see the additional script changing the caption colour:

this.caption.font.fill.color.value = "255,255,255";

Yes, once you are happy with the object, drag it back into the Object library and it will be available in any form. You can always update it later if needs be.

Also a good technique is to select and object and go to Edit / Copy multiple. This allows you to quickly copy objects down and across at a set spacing.

The Adobe guide for expanding a object to match the contents works for a textfield, but not a dropdown list. See example in form. The Dropdown list cannot be set to expand to fit" in the Layout tab.

Hope that helsp,

Niall

Avatar

Level 2

Hello,

I pretty much have this form licked but..... One of the guys in the shop had an idea if they clicked onto the button and then entered the letter on the keyboard it would be a lot quicker for them to fill out the form (not so many clicks) they could just type in "A" "R" "S" or "N" instead of clicking up to three times. Is this possible?

Thanks in advance

John

Avatar

Level 2

I am just about done with the form but.... one of the guys in the shop had a suggestion.

He was wondering instead of clicking several times on the buttons to change them could he click on the button then press a letter on the keyboard to change the button so he would not have to click so many times. Is this possible?

Thanks in advance

John

Avatar

Level 10

Hi,

The form looks good!! Teamwork!!

I don't think that you will be able to script for a user clicking a letter and the button going to that state. The letters are in the caption of the button. Buttons do not have values.

However there is a feature of a button that will help. Once the user has clicked on a button, it still has focus until the user goes into another object (like a dropdown or button). So it could work like this:

  1. User clicks a button;
  2. While moving nouse over to the dropdown, presses enter/return on the keyboard repeatedly until reaching the right state. This is equivalent to clicking the button;
  3. Once the button is correct they can then enter the dropdown.

Not much quicker, but at least it uses both hands and once the user is positioned over the enter/return key, they do not need to look at the keyboard anymore and can focus on the screen.

Good luck,

N.

ps just a small sugestion: in the ss category, I would be inclined to look at "dangerous safety". Maybe "unsafe to drive". Just a suggestion!!

Avatar

Level 2

Niall,

Hey how are you? I have had to put the form aside for awhile but I am trying to complete it now. I have one last question about tab order.

I have been trying to get the tab order correct for about six hours now ARRGH! Maybe you can look at this thing and see what is wrong. What happens is I get a few of the fields correct with the tab order then the sixth one keeps reverting to 150 (maybe more fields will do this I don't know though). I don't know what is wrong could you please please help!

Thanks in advance

John

P.S. I did get the long dropdown to work using Excel to merge colums together to get the tags <text> & </text> on either side of the list in XML once i figured out what to in Excel the rest went smoooth!

Avatar

Level 10

Hi,

Tabbing can be a real pain.

The tabbing order can be seriously affected by the x, y coordinates of the objects in the form. For example if an object on the right of the form is slightly higher than an object on the left then it will tab first. This was covered in one of the MAX online sessions, but I can't remember which one.

Also when you tab into an object that is in a subform, then the tabbing will work through all objects in that subform before progressing out of the subform.

At present you have objects in subforms named to suit the topic. This is fine, but it means that subforms are overlapping and have differing x, y coordinates. Some subforms are pushed right up to 0,0 for no reason. This is screwing up tabbing.

So, I would recommend setting the tabbing to automatic.

Then unwrap each subform (particularly those that are bigger than the objects that they contain). NOTE: Only unwrap one subform at a time, to make it easier to reselect objects. Then select the objects again and wrap in a subform. Where a topic spans two columns, I would have two subforms "maintenance1" and "maintenance2".

Then select each subform and check that the x coordinates of the top subforms are exactly the same (go to the Layout tab). Then for each subforms in a column check that the y coordinates are exactly the same.

We are getting close; lastly wrap each of the subforms in a column in a new subform. You should end up with five subforms.

Now when you click into "Lights" it will tab all the objects in the first column before progressing to the next.

I have this working in the uploaded revision, but I don't have the fragments, so the form may have lost the linkage.

Hope that helps,

Niall

Avatar

Level 2

Niall,

Looks cool but what happens when the buttons are added to the drop down lists? I see you got it all tabbed correctly but you did not have the buttons, I sent the file to see if you can get them to work in the tab order. The order would go thru the info box then the first button then the "Lights" drop down to the next button to "Horn" and so forth. Man I really got to thank you for your help I struggled with this till about 2AM!!@%@%

Thanks in advance

John

Avatar

Level 10

Hi John,

I have closed down for the night (and possibly tomorrow as well).

The buttons are fragments, so I don't see them over here when I edit the form in LC.

In order for the button to get focus first it would need to be higher than the dropdown.

One work around would possible be to set the anchor point of the button at the top (Layout tab) and the anchor of the dropdown at the bottom. This might fool Acrobat in thinking that the button is higher, when in fact it is not. Relative y coordinates.

As I say I am not able to test this at the moment and I would need the form with the buttons. You may have already uploaded.

Have a good weekend,

Niall

Avatar

Level 10

Hi John,

My work around didn't work. When an object's anchor is set to top left, then the dimensions are "x" and "y". However when you change the anchor to something else, like bottom right, the Layout tab shows "anchor x" and "anchor y", so it doesn't affect tabbing.

NanoSnapper1.png

I couldn't get the XDP to work, so here is a sample, of two textfields and a button. Because the y coordinate of the button is lower than the other textfields it tabs last.

I think you are going to have a bit of a problem here. Basically because the button is smaller and the y coordinates are below the dropdown field, the button will tab AFTER the dropdown.

I can't think of any other work around at the moment.

You could start again down the route of custom tabs. This may work better now that the other objects are more controlled.

Good luck,

Niall

Avatar

Level 2

Niall,

Long time no talk. Well I had to take a hiatus from the from got it almost done but the coloured boxes don't reset when you push the reset form button on the form. All the text fields clear out but the buttons don't all go back to the "A" state, Is it because of the script?  Any help would be appreciated I sure would like to get the form to totally reset.

Thanks in advance

John

Avatar

Level 2

There is no option to upload the form I am working on in the editor how do I add an attachment? I want to send my form.

Avatar

Level 10

Hi John,

The last version I have is 29 Nov 2009, where the buttons were fragments. However here is an earlier version with a reset button: https://acrobat.com/#d=*ir-pN0HBWuPVVNZJ3m5qw

The problem is that the button does not have a default state, so the reset button does not have any effect. For each button you would need to include three lines of script to restore the button to what ever state you want (here, green 'A').

bodyButton1.border.fill.color.value = "0,157,2";

bodyButton1.caption.value.text = "A";

bodyButton1.caption.font.fill.color.value = "255,255,255";

I appreciate that this is going to be a bit of script for the 70 buttons, but I can't see any other way.

The ability to upload files is temporarily turned off. You can upload files to Acrobat.com or YouSendIt.com. Just load, publish and then post the link.

Hope that helps,

Niall

Avatar

Level 2

Naill,

So the fun really is starting now!

1.  Does the code go at the end of the script or the beginning?

2.  Should I just modify the fragment that I am using then re-do all the buttons on the form.Or copy all the XML into a word processor and add the rest of the script in?

Let me know what you think.

Man I have to really thank you for ALL your help thus far this thing has reall turned into a project hasn't it!

All the best

John

Avatar

Level 10

Hi John,

If you can add script to your fragment that will automatically be applied to all buttons, then I would add the following to the 'full' event:

this.border.fill.color.value = "0,157,2";

this.caption.value.text = "A";

this.caption.font.fill.color.value = "255,255,255";

If this is the default state that you want for the button.

The full event fires when a field has reached its capacity, which is not applicable in a button. This is why I am suggesting it for the default state, becuase we can call this in one line in the click event of the reset button.

xfa.host.resetData(); // reset data

bodyButton1.execEvent("full"); //fire the full event to set each button to default state

bodyButton2.execEvent("full");

bodyButton3.execEvent("full");

bodyButton4.execEvent("full");

...

The real advantage of this approach will be if the script added to the fragment carries across to all buttons.
Order up the black coffee ;-)
Niall