Expand my Community achievements bar.

SOLVED

Trouble with captions...

Avatar

Level 10

Trying to get some caption switching working and having trouble. Trying to use a dropdown to change the caption of another dropdown.

Tried a switch statement with no luck (commented out at the bottom of the code block below) - caption wouldn't change at all.

Currently trying a bunch of if...else statements but I have to select from the first dropdown twice to get the caption to show up - or if I select another value from the dropdown it shows the caption that matches the previous selection.

I have the feeling I'm missing something simple.

if (this.rawValue=="CHQ Returned Undeliverable Cheque")
    {
        xfa.resolveNode("ReasonList.caption.value.#text").value = "Returned Undeliverable Cheque";
    }
else if (this.rawValue=="CHQ Stop Payment - Cheque Attached")
    {
        xfa.resolveNode("ReasonList.caption.value.#text").value = "Cheque Attached";
    }
else if (this.rawValue=="CHQ Stop Payment - No Cheque Attached")
    {
        xfa.resolveNode("ReasonList.caption.value.#text").value = "No Cheque Attached";
    }
else if (this.rawValue=="Restricted Codes")
    {
        xfa.resolveNode("ReasonList.caption.value.#text").value = "Restricted Codes";
    }
/*
switch(this.rawValue)
    {
        case "CHQ Returned Undeliverable Cheque":
            xfa.resolveNode("ReasonList.caption.value.#text").value = "Returned Undeliverable Cheque";
        break;
    }
*/
1 Accepted Solution

Avatar

Correct answer by
Level 2

I'm just a newbie at this, so this might not be the answer you're looking for... but a switch statement seems to do the trick for me.

If you turn on "specify item values" on the binding tab of your drop down list and on the change event put this:

Wouldn't this work?

var newValue = this.boundItem(xfa.event.newText);

  

switch(newValue)

    {

    case '0':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "Returned Undeliverable Cheque";

    break;

    case '1':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "Cheque Attached";

    break;

    case '2':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "No Cheque Attached";   

    break;

    case '3':

          xfa.resolveNode("ReasonList.caption.value.#text").value = "Restricted Codes";

     break;

    case '4':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "Returned Undeliverable Cheque";

    break;

  

      }

View solution in original post

3 Replies

Avatar

Correct answer by
Level 2

I'm just a newbie at this, so this might not be the answer you're looking for... but a switch statement seems to do the trick for me.

If you turn on "specify item values" on the binding tab of your drop down list and on the change event put this:

Wouldn't this work?

var newValue = this.boundItem(xfa.event.newText);

  

switch(newValue)

    {

    case '0':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "Returned Undeliverable Cheque";

    break;

    case '1':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "Cheque Attached";

    break;

    case '2':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "No Cheque Attached";   

    break;

    case '3':

          xfa.resolveNode("ReasonList.caption.value.#text").value = "Restricted Codes";

     break;

    case '4':

        xfa.resolveNode("ReasonList.caption.value.#text").value = "Returned Undeliverable Cheque";

    break;

  

      }

Avatar

Level 10

Thanks! Perfect.

The "boundItem" was exactly what I was looking for in my other thread too.

It now switches the caption value on the first click too - don't know why it wouldn't do it before.

Avatar

Level 2

That's great. I'm glad that worked.

I find drop down lists a little tricky. I've had the same problem with them not showing the current value on selection, when I want to push that value to another element - like a text field.

I did find that this seem to worked at the time:

TextField1.rawValue = xfa.event.prevText;

Thanks!

Connie Cassidy