Expand my Community achievements bar.

SOLVED

Message into DD list in case of custom entry

Avatar

Level 7

I have a Drop down list which allows custom entry.

There any way if the user starts to type a new item into DD a message should pop up" Please something...."?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

If you do not want the message to fire when the user selects from the drop-down, the change event below is as close as you are going to get I think. However, the message box doesn't fire until the user enters the first character.

I have a drop-down called 'stooges' that allow custom entry and contains the list items 'Larry', 'Curly', and 'Moe'.

// form1.page1.subform1.stooges::change - (JavaScript, client)

if (xfa.event.newText != "Larry" && xfa.event.newText != "Curly" && xfa.event.newText != "Moe") {

  xfa.host.messageBox("Are you sure it is not Larry, Curly, or Moe?");

}

Steve

View solution in original post

5 Replies

Avatar

Correct answer by
Former Community Member

If you do not want the message to fire when the user selects from the drop-down, the change event below is as close as you are going to get I think. However, the message box doesn't fire until the user enters the first character.

I have a drop-down called 'stooges' that allow custom entry and contains the list items 'Larry', 'Curly', and 'Moe'.

// form1.page1.subform1.stooges::change - (JavaScript, client)

if (xfa.event.newText != "Larry" && xfa.event.newText != "Curly" && xfa.event.newText != "Moe") {

  xfa.host.messageBox("Are you sure it is not Larry, Curly, or Moe?");

}

Steve

Avatar

Level 7

Thanks Steve for your help, it's work fine!

Just one more question: In my case to apply your script was easy(I have only 5 items into DD).

What about if the DD contains a lot of Items, what kind of script we have to apply?

Thanks Steve

Avatar

Former Community Member

This is a bit of hack...but it works.

// form1.page1.subform1.stooges::change - (JavaScript, client)

var itemCnt = form1.page1.subform1.stooges.length;

var matchFound = false;

for (var i=0; i < itemCnt; i++) {

  if (xfa.event.newText == form1.page1.subform1.stooges.getDisplayItem(i)) {

    matchFound = true;

  }

}

if (matchFound == false) {

  xfa.host.messageBox("Are you sure it is not Larry, Curly, or Moe?");

}

Avatar

Level 7

Thank you again for all your help Steve!

When I try to type a new item into DD the message repet itself again and again for every character I type...

Thanks

Avatar

Level 10

Move the code from Change event to Exit event of the DD List.

Thanks

Srini

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----