Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Selecting Text Box to change Text Field

Avatar

Level 1

I've been working on a form to allow providers to fill out their Endoscopy reports online.  I'm trying to do something very simple.  If a user selects a checkbox change the value within a Text Field.  Either one allows the code to run once.  It will change the value one time - even though I think it is putting the wrong value in the code - but that is neither here nor there at this point.

Here is the code I believe should work.

form1.EndoscopyPage1.TestChkBox::click - (JavaScript, client)

if (this.rawValue == 1)

{

TestTxt1.rawValue = "ON"; // user cannot enter field

}

else

{

TestTxt1.rawvalue = "off" ; // user can enter field

}

I've tried the following as well

//if (TestChkBox.value = 0) then

//   TestTxt1.editValue = "Off";

//endif;

//if (TestChkBox.value = 1) then

//  TestTxt1.editValue = "ON";

//endif;

I've attached the file as well.  My test fields are in the middle of the first page.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Its just a typo mistake. You typed rawvalue instead of rawValue  'V' must be upper-case.

See the snap attahed.  It works for me after changing that property.

Nith

View solution in original post

7 Replies

Avatar

Former Community Member

The method you want is access and if you want to lock the field set it to readOnly and if you want to allow entry set it to "". So your code shoudl look like this:

Paul

Avatar

Level 1

Paul,

Thanks for the advise.  I guess the words "ON" and "OFF" may be confusing.  I'm not trying to turn off access or turn on access to the text field.

I'm trying to put a string within the text box.  For example, I'd Like to put "Endoscopy procedure lower was normal" within the text box if it is selected.  If it is not selected I'd put "Endoscopy procedure was abnormal".

The file is attached in original email.

Avatar

Former Community Member

Then the rawValue is what you want .....the code will look like this:

Paul

Avatar

Level 1

That is really what I have.  It doesn't work. 

If you run the attached file, you will see.

If I place a check mark in the checkbox, It changes it once and only once.  If I select it the first time, it will type in "OFF" <which it should be on because of the 1> but it is wrong.  The next time I unselect it - it doesn't do anything.  It should do something, but it doesn't.

Avatar

Level 4

Okey... I am not quite sure if I can help much...

On which event did you put it? I'd put it on change...

Well, then check out if your "on" and "off" values really are really what you asked for. If they are and it still won't work, you could try to make 2 if sentences instead of an if...else.

Avatar

Correct answer by
Level 10

Its just a typo mistake. You typed rawvalue instead of rawValue  'V' must be upper-case.

See the snap attahed.  It works for me after changing that property.

Nith

Avatar

Level 1

The last thing helped.  So frustrating working 2 - 3 hours on a problem and the only thing it was - A Capital Letter.

Thanks