Expand my Community achievements bar.

SOLVED

How to populate a textfield based on a dropdown list and a checkbox

Avatar

Level 3

Hi Guys,

I need help.
first step: I have a dropdown list if i click in dropdownlist "a" and put in numeric field a number bigger than 99 the, checkbox should be marked and  second step: a textfield1 should be visible.

the first step works perfectly but the second doesnt work.
this is my coding for the second step in event : change java script

if ((DropDownList1.rawValue == "a") && (this.rawValue == 1))
{
TextField1.presence = "visible";
}
else
TextField1.presence = "hidden";


does anybody have any idea why?

thanks!!

Diana

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Diana,

You are on the right track. deleteItem is zero based; so if you want to delete the second item it would be deleteItem(1).

I would recommend similar script in the dropdown exit, so that if the user goes back there and changes that value, the same logic will be applied. Also when you are deleting dropdown items using script, it is useful to addItem() again in the else part of the if statement. This way you can restore the list as the form is changed.

Also I would wrap the script in the numberField in another if statement to first check for null.

Example attached.

Good luck,

Niall

View solution in original post

6 Replies

Avatar

Level 10

Hi,

I would put the following in the exit of the dropdown and the checkbox:

if

(DropDownList1.rawValue == "a" && CheckBox1.rawValue == 1)

{

TextField1.presence

= "visible";

}

else

{

TextField1.presence

= "hidden";

}

(the script is all over the shop, but should be OK in the form).

Then in the exit event of the numeric field (after the changing of the checkbox value) you could call the checkbox exit event.

Good luck,

Niall

Avatar

Level 4

Withdrawn...i understand what is going on now

Avatar

Level 3

Thank you so much it works perfectly!!!!

Avatar

Level 3

Just another quick question.

I changed the textfield in dropdown list and try to delete one item in this dropdown list with:

DropDownList.deleteItem (2)

it deletes the third item but not the value 2, value 2 is"sie"

can u help me please!!

thank u!!

Diana

Avatar

Correct answer by
Level 10

Hi Diana,

You are on the right track. deleteItem is zero based; so if you want to delete the second item it would be deleteItem(1).

I would recommend similar script in the dropdown exit, so that if the user goes back there and changes that value, the same logic will be applied. Also when you are deleting dropdown items using script, it is useful to addItem() again in the else part of the if statement. This way you can restore the list as the form is changed.

Also I would wrap the script in the numberField in another if statement to first check for null.

Example attached.

Good luck,

Niall

Avatar

Level 3

Hi Niall,

thanks a lot!!

it works perfect

Diana