These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

The number remains but hidden?

RustyWood
Registered: Mar 16 2010
Posts: 83
Answered

Thank you Jim I found this calculation of yours and it came in very helpful but;

I have three radio buttons in a group 1 2 + 3 if you sellect 3 allows you to add into text box "participant_1_quantity_additional_packs" a value

getField("participant_1_quantity_additional_packs").hidden = (Number(getField("partcipant_1_check_box").value) < 3);
I'm trying to return "participant_1_quantity_additional_packs" back to zero if 1 or 2 are then checked such as if the client had made a mistake, the number in "participant_1_quantity_additional_packs" the number remains but hidden, so messing up my other calculations

getField("participant_1_quantity_additional_packs").hidden = (Number(getField("partcipant_1_check_box").value) < 3);//
else if(Number(getField("partcipant_1_check_box").value) < 2)
("participant_1_quantity_additional_packs") = "0";

Obviously I know this is incorrect but this is the sort of calculation I'm trying to get if it makes any sense at all??
Of course i'm getting a syntax error 2: at line 3 as well !!!

I have tried a few things but as you know my Javascript is very limited

With thanks

Rusty

My Product Information:
Acrobat Standard 9.3.1, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
An 'else' can only be used if there is [b]preceding[/b] 'if'.

You continue to write very incomplete code or do not order the statements of code in the correct sequence. Please look at the tutorials, articles, eSiminars on demand at this site please to learn how to create simple JavaScript statements.

If you are going to hide a field because a logical condition has been met, then you should have some code that will display that field if the condition is not met. You can set the field to be displayed before testing for the value that will hide field or you provide and 'else' block of code to display the code. So when the entire script has run, the field is either displayed or it is not displayed. It is not entirely clear what you are trying to do. I would guess you want a field's value set to zero and hidden when another field has a value less than 2.

// assume the field is to be displayedthis.getField("participant_1_quantity_additional_packs").display = display.visible;if( Number(this.getField("partcipant_1_check_box").value) < 2) {// hide the field only when "partcipant_1_check_box" is less than 2this.getField("participant_1_quantity_additional_packs").display = display.hidden;// set the value of the hidden field to zerothis.getField("participant_1_quantity_additional_packs").value = 0;} // end of true result block of code

[url=http://www.acrobatusers.com/tutorials/2006/show_hide_fields]Hiding and Showing Form Fields[/url] by Thom Parker

George Kaiser

RustyWood
Registered: Mar 16 2010
Posts: 83
Thank you once again

I was originally getting the result I wanted with this:

getField("participant_1_quantity_additional_packs").hidden = (Number(getField("partcipant_1_check_box").value) < 3);
But then I realised the number was still remaining but hidden, that was the problem.


I changed the line of code in your calculation  if( Number(this.getField("partcipant_1_check_box").value) < 2)
to a value of < 3 and that's exactly what I was trying to do.. Yes I do need a lot more understanding of JavascriptWhen I first looked at forms I didn't realise it would involve so much behind the scenes Java Script.

Thanks Again for all your help
RustyWood
Registered: Mar 16 2010
Posts: 83
Hello
I have had to change the radio boxes to check boxes which I was using before, so I could have an easier count total.

The script below is now hiding the field "participant_1_quantity_additional_packs" when "participant_1_check_box_1" is checked which is what I want.

But "participant_1_quantity_additional_packs" is still showing when "participant_1_check_box_2" is checked.

I am trying to only allow an amount to be added to "participant_1_quantity_additional_packs" when "participant_1_check_box_1" has been checked.

Again any insight into this would be appreciated

Thank You



// assume the field is to be displayedthis.getField("participant_1_quantity_additional_packs").display = display.visible;if( Number(this.getField("participant_1_check_box_1","participant_1_check_box_2").value) < 3) {// hide the field only when "participant_1_check_box_1" is less than 3// hide the field only when "participant_1_check_box_2" is less than 3this.getField("participant_1_quantity_additional_packs").display = display.hidden;// set the value of the hidden field to zerothis.getField("participant_1_quantity_additional_packs").value = 0;} // end of true result block of cod
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Read you comments and make the logical statement of the 'if' statement match what your are describing. Also you might want to create some variables so you can more easily see what you are writing.

The statements:
Quote:
// hide the field only when "participant_1_check_box_1" is less than 3
// hide the field only when "participant_1_check_box_2" is less than 3
is not very clear as to what should happen if one is three or more.

var nPartic1pant1 = Number(this.getField("participant_1_check_box_1").value);var nParticipant2 = Number(this.getField("participant_1_check_box_2").value)var Participant1_Add_Packs = this.getField("participant_1_quantity_additional_packs")// assume the field is to be displayedParticipant1_Add_Packs.display = display.visible;// test for both participant packs being less 3if( (nPartic1pant1 < 3) & (nPartic1pant2 < 3) ) {// hide the field only when "participant_1_check_box_1" is less than 3// hide the field only when "participant_1_check_box_2" is less than 3Participant1_Add_Packs.display = display.hidden;// set the value of the hidden field to zerothis.getField("participant_1_quantity_additional_packs").value = 0;} // end of true result block of code

And exactly in what action and field is this code associated with?

If it is one of the fields, you should be using the 'event' object as the named field will not be updated until you exit the field.

George Kaiser

RustyWood
Registered: Mar 16 2010
Posts: 83
Sorry I have yet to get this calculation to work,
If I use this script "participant_1_quantity_additional_packs" stays visible,

I had every thing working but I had to change the mutually exclusive radio button group I had into a checkbox mutually exclusive group.

I have
"participant_1_check_box_1" = value of 1
"participant_1_check_box_2" = value of 2
"participant_1_check_box_3" = value of 3

then a text box

"participant_1_quantity_additional_packs"

only when "participant_1_check_box_3" has been checked it will allow you to enter a number into this text box.


var nParticipant1 = Number(this.getField("participant_1_check_box_1").value);var nParticipant2 = Number(this.getField("participant_1_check_box_2").value);var Participant1_Add_Packs = this.getField("participant_1_quantity_additional_packs");// assume the field is to be displayedParticipant1_Add_Packs.display = display.visible;// test for both participant packs being less 3if( (nParticipant1 < 3) & (nParticipant2 < 3) ) {// hide the field only when "participant_1_check_box_1" is less than 3// hide the field only when "participant_1_check_box_2" is less than 3Participant1_Add_Packs.display = display.hidden;// set the value of the hidden field to zerothis.getField("participant_1_quantity_additional_packs").value = 0;} // end of true result block of code

Thank you for your Help once again