Expand my Community achievements bar.

SOLVED

drop-down list - working with default value

Avatar

Former Community Member

Hello,

we have drop down list with enabled option "Allow Custom Text Entry" (combo-box). We need to display as a default value text : "-- Choose or Type --".

After the drop down list get focus, we need to make the field empty, so the user does not need to delete the text "-- Choose or Type --".

Then, when user does not choose or type anything and exits the drop-down list, we need to display "-- Choose or Type --" again.

If the only option is to have the value "-- Choose or Type --" as one of list items, we need, that it have value null, empty string or false.

Is there a way to do this ?

The best result I get is when in enter event is set this.rawValue = ''  -> field becomes empty but I have not fond the way how to set again the value to "-- Choose or Type --". Even calling xxx.selectedIndex=0; or xxx.setItemState(0,true); in exit action does nothing.

I know it would work, if the "-- Choose or Type --" has value e.g. '000', but this is quite big change for validation scripts, that we cannot accept in this phase of project.

Thanks for any advice.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,  I have a sample of using "Ghost Text", that might help.  http://cookbooks.adobe.com/post_Adding_Ghost_Text_to_LiveCycle_Designer_form-18436.html.  This displays some text using the "null' display pattern, so you get the text displayed but it does not effect the value of the field.

Bruce

View solution in original post

6 Replies

Avatar

Level 10

I have done a sample form with your requirement.

Let me know this is what you want..

See the sample attached here

Nith

Avatar

Former Community Member

Thank you very much for your sample Nith.

The user experience is exactly what we wanted. The only problem is, that we cannot use strigt 'false' as a value / key for the item '-- choose or type --'.

I gues you run to the same issue as I did, when using empty value instead. It seems, that item with this value cannot be programaticly set as the selected one.

We need to use empty value, because otherwise it needs to change validation logic, that would need to know, that the value 'false' is the same as empty.


Regards.

Avatar

Correct answer by
Level 10

Hi,  I have a sample of using "Ghost Text", that might help.  http://cookbooks.adobe.com/post_Adding_Ghost_Text_to_LiveCycle_Designer_form-18436.html.  This displays some text using the "null' display pattern, so you get the text displayed but it does not effect the value of the field.

Bruce

Avatar

Former Community Member

Thank You for your advice and example Bruce, I didn't know, that it could be so easy.

The only disadvantage I noticed is, that when I enter the field, type some value, exit (give focus to another field), again enter the field, delete value and exit - then the null value is not displayed again.

Anyway, this is best solution I have seen. Lets have customer to choose...

Thanks again Nith and Bruce.

Avatar

Level 10

Hi,  I had not noticed this behaviour before and it doesn't happen in Reader 8 so I think it might be a new "feature".  Looking at the form template (using console.println(this.saveXML("pretty")) in the exit event it seems that there's a "value" element left hanging around.

If you remove it things seem to work as expected, so you could add the following code to the exit event.

var v = this.getElement("value");
if (v.text.isNull)
{
this.nodes.remove(v);
}

Good luck

Bruce

Avatar

Level 5

Ahhh yes! It's a beautiful thing when it all works. Thanks BR001! Here is my script for a dropdown box. Dropdown box name is edited with ellipse due to long name. All the best.

//form1.....dFocal::enter - (JavaScript, client)

this.fontColor = "0,0,0";

this.font.posture = "normal";

//form1.....dFocal::exit - (JavaScript, client)

var v = this.getElement("value");

if (this.isNull)

{

  this.fontColor = "153,153,153";

  this.font.posture = "italic";

  this.nodes.remove(v);

  //console.println("This value equals" + "<" + this.rawValue + ">");

}

//form1.....dFocal::ready:form - (JavaScript, client)

this.execEvent("exit");

this.format.picture.value = "null{' Last, First MI'}";