We hope you'll join us for our 4/23 webinar on using data tables to apply reference ranges and AE codes in OC4. For more information and to register, visit https://register.gotowebinar.com/register/2882170018956684555

Accessing .val() on hidden fields or variables from previous sections

Hi all

Hoping someone has seen this before and can point me in the right direction. We're just setting up our first CRF in openclinica and looking into rules/validation in terms of simple conditional, rules and javascript directly in the XL file.

We have a CRF that is split into sections (demographics etc.) in a logical order. I'm performing an on the fly calculation on one of the variables, the result of which is displayed in the right item text field called on the field change. The calculation needs to access information entered in an earlier section (same CRF), I tried using the usual $("#Holdl1MessageDiv").parent().parent().find("input") and val() method. This returns as undefined which leads me to believe that variables from other sections cannot be accessed on the file using javascript, only at save through rules.

My next idea was to create a hidden field on the section that the calculation is being run on, and assign it the same value as the field of interest from the earlier section on save of that earlier section, then use the hidden variable in the calculation. This appeared to work well, whilst testing the 'copy' field was set to 'show' to make debugging a little easier; the value was copied successfully and the calculation ran fine using this copied value. However, as soon as the copy was changed to 'hide' the .val() function again returns undefined. I'd rather not have to 'show' this duplicated field just to get the calculation to work.

Does anyone have any idea how to resolve the above or a viable workaround?

Thanks in advance



  • GerbenRienkGerbenRienk ✭✭✭ Posts: 818 ✭✭✭
    Hi Alan,
    Your presumption is correct: CRF-items from others sections can not be referred to using javascript.
    But: you can use the tokens-functionality as of release 3.3
    It sounds like this is your answer. Have a look at the attached CRF.
    Kind regards,
    Gerben Rienk
  • alan.rossingtonalan.rossington Posts: 9
    Hi Gerben Rienk

    Many thanks for your help and the CRF!

    Unfortunately we're currently on an older version of OC, however based on your feedback we're going to upgrade shortly to enable the token functionality, which from your CRF looks like exactly what I need.

    Thanks again
This discussion has been closed.