Accessing field value from form that is used in Subform Repeater

Confluence User - 29 Aug, 2016

Hi everyone,

I am using the Subform Repeater Plugin, which is great for many many scenarios!

However, now I stumbled across an obstacle where a custom html field that tries to access a field value from another form field fails to retrieve the data when being used inside a subform repeater wrapper.

Usually I would use Javascript code like this in the form that is now used for the subform repeater:

        var d1 = "status_new";
        var d2 = "status_current";  
        //get values
        var d1Val = $('[name='+d1+']:enabled').val();
        var d2Val = $('[name='+d2+']:enabled').val();

 

However, since the Subform Repeater creates multiple rows based on the same form, the field id seems to be changed dynamically to something like "12315342_step1_status_new", "2314422_step1_status_new" and so on (depending on the row).

Therefore the JS code above fails as it can't find "status_new".

 

Any suggestions how I can make that work with some JS magic, champs?

Cheers,

Eric

forms;javascript;customhtml;field

1


31 Aug, 2016
confluenceUser
confluenceUser

Hi,

I'm no JavaScript expert, but perhaps instead of using the JQuery attribute equals selector, you could use the attribute ends with selector (https://api.jquery.com/attribute-ends-with-selector/)?

 

RELATED QUESTIONS

Your answer


To answer a question you'll need an account.

Print