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

Fill a form based on other text field

Suminers
Registered: Dec 31 2007
Posts: 5

Hi to you all and a happy new year to everyone!!

Now to my question.

I'm not a programmer, so I basically don't understand much of JavaScript, just the logic behind it, but not the commands, with that said, I'm looking for a "script" to do this:

get the number from one text box (which is formatted "number") and based on that value fill another text box.

Example:

If I type "3" on text box 1, text box 2 should be filled with the number "-5"
If I type "5" on text box 1, text box 2 should be filled with "-4"...

So can someone help me?!

Thanks in advance.

PS: I searched the forums and found nothing related to this question.

lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
Thom Parker has an article on "Hiding and Showing Form Fields" that will help you with this at:
http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/show_hide_fields/

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

Suminers
Registered: Dec 31 2007
Posts: 5
Are you sure that you understood my question? 'Cause I didn't find what I was looking for there.

But thanks anyway...
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
The value of a field is a property of the field object just like the visibility. Since the exact code will depend on which program you use to create the form and upon which field and event you place the code at.

For Acrobat FormTool for the "On Blur" action for the "test box 1" field:

// if this field has a value of 3
if (this.getField(event.target.name).value == 3) {
// then text box 2 is equal to -5
this.getField("text box 2").value = -5;
}

// if this field has a value of 5
if (this.getField(event.target.name).value == 5) {
// then text box 2 is equal to -4
this.getField("text box 2").value = -4;
}

Or one can use the "switch" statement

switch (this.getField(event.target.name).valueAsString) {

case "3": // value is 3
this.getField("text field 2").value = -5;
break;case "5": // value is 5
this.getField("text field 2").value = -4;
break;default:
// any other action
break;
} // end switch

George Kaiser

Suminers
Registered: Dec 31 2007
Posts: 5
gkaiseril, thank you very much!!! :D
justlearning
Registered: Jul 18 2009
Posts: 6
I'm new here, so please don't kill me for asking really really really dippy questions!

I've made a PDF order form.

I have a radio button for them to select a thing called Reverse. If they check it, the Export Value is also Reverse.

I have another field that I want to fill in the price if they check the radio button, and leave it blank if they don't.

I've read all the posts here I could find. I've tried every combination of things I can find, and I'm still not getting it to do it. Part of my problem, I think, is that this is all such new stuff to me that I'm getting lost in examples that aren't as simple as this, or that over explain. I'm actually smart girl. Once I see one done correctly and get it to work, I'll be off and running!

So - can anybody help?

In my clumsy incorrect script, I'd be doing:

If Reverse=reverse, then 100

It's amazing how software can make smart people feel really dumb!

justlearning
Registered: Jul 18 2009
Posts: 6
oh, and I have no idea why it thinks I registered in 1969. I just got here now, in 2009! I was only 11 years old in 1969, and this forum didn't even exist!

It's amazing how software can make smart people feel really dumb!

lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
justlearning wrote:
oh, and I have no idea why it thinks I registered in 1969. I just got here now, in 2009! I was only 11 years old in 1969, and this forum didn't even exist!
It's just a registration issue that we're working on.

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.