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

Openclinica comment javascript

Hello Friends,
This is the first time i am trying to use javascript to do a simple calculation.
I want to access the values from two field do calcualtion and save it into other input.
The javascript is not running and after looking on the code using developer tools IE i found out the code has been commented using
Here is the steps i followed.
1-
Volume of blood donation in the next 4 months
2-
Systemic antibiotics
3- Volume of blood to be obtained
on the rightText box i have my code which
jQuery(document).ready(function($) {
var v1, v2, v3;
v1 = $("#cal_v1").parent().parent().find("input");
v2 = $("#cal_v2").parent().parent().find("input");
var calcel = $("#cal_rec").parent().parent().find("input");
var res = 450 - (v1 + v2);
cal_res.attr("readonly", true);
calcel.value(res);
calcel.change();
}
Thanks in advance :)
--
Yama Farooq,

IT Manager, University of Oxford

Comments

  • haenselhaensel Posts: 602 ✭✭✭
    Hi Yama Farooq
    I can't help you with the comment out code but there are some little
    bugs in your JavaScript code.
    1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    2. cal_res.attr("readonly", true); => calcel.attr("readonly", true);
    3. var res = 450 - (v1 + v2); => var res = 450 - (v1.value()
    + v2.value());
    Regards,
    Christian
    ------------------------------------------------------------------------
    Dipl.-Inf. Christian Hänsel

    IT / Software Developer
    Tel.: +49-(0)89-5526189-16
    Fax : +49-(0)89-5526189-55
    E-Mail: [email protected]
    ReliaTec GmbH
    Schleissheimer Str. 37
    85748 Garching Germany
    HRB 150060 / AG München
    Gf Thomas Herbig
    http://www.reliatec.de
    =========================================================================
    Am 18.11.2013 17:16, schrieb Yama Farooq:
    > > Hello Friends,
    > >
    > > This is the first time i am trying to use javascript to do a simple
    > > calculation.
    > >
    > > I want to access the values from two field do calcualtion and save it into
    > > other input.
    > >
    > > The javascript is not running and after looking on the code using developer
    > > tools IE i found out the code has been commented using
    > >
    > > Here is the steps i followed.
    > >
    > > 1-
    > > Volume of blood donation in the next 4 months
    > >
    > > 2- Systemic antibiotics
    > >
    > > 3- Volume of blood to be obtained
    > >
    > > on the rightText box i have my code which
    > >
    > >
    > > > lang="Javascript">jQuery(document).ready(function($) {
    > > var v1, v2, v3;
    > > v1 = $("#cal_v1").parent().parent().find("input");
    > > v2 = $("#cal_v2").parent().parent().find("input");
    > > var calcel = $("#cal_rec").parent().parent().find("input");
    > > var res = 450 - (v1 + v2);
    > > cal_res.attr("readonly", true);
    > > calcel.value(res);
    > > calcel.change();
    > > }
    > >
    > >
    > >
    > > Thanks in advance
  • GerbenRienkGerbenRienk Posts: 814 ✭✭✭
    Hello Yama,
    The fact that you code is commented out should not be a problem, because
    all RIGHT_ITEM_TEXT appears double in the CRF: first commented out and
    then for real.
    Further to Christian's suggestions I would say that the script below
    should do the job.
    Kind regards,
    Gerben Rienk
    http://www.trialdatasolutions.com
    Volume of blood to be obtained


    $.noConflict();
    jQuery(document).ready(function($) {
    var v1 = $("#cal_v1").parent().parent().find("input");
    var v2 = $("#cal_v2").parent().parent().find("input");
    var calcel = $("#cal_res").parent().parent().find("input");
    function doTheCalc(){
    var res = 450 - v1.val() - v2.val();
    // only write the result if it is different from what is already there
    if (res != calcel.val()){
    calcel.attr("readonly", true);
    calcel.val(res);
    calcel.change();
    }
    };
    // calculate if anything changes in v1
    v1.keyup(function(){
    doTheCalc();
    });
    // calculate if anything changes in v2
    v2.keyup(function(){
    doTheCalc();
    });
    // calculate when the page is loaded
    doTheCalc();
    })

    > > Hi Yama Farooq
    > >
    > > I can't help you with the comment out code but there are some little
    > > bugs in your JavaScript code.
    > >
    > > 1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    > > 2. cal_res.attr("readonly", true); => calcel.attr("readonly", true);
    > > 3. var res = 450 - (v1 + v2); => var res = 450 - (v1.value()
    > > + v2.value());
    > >
    > > Regards,
    > > Christian
    > >
    > > ------------------------------------------------------------------------
    > >
    > > Dipl.-Inf. Christian Hänsel
    > >
    > > IT / Software Developer
    > >
    > > Tel.: +49-(0)89-5526189-16
    > > Fax : +49-(0)89-5526189-55
    > > E-Mail: [email protected]
    > >
    > > ReliaTec GmbH
    > > Schleissheimer Str. 37
    > > 85748 Garching Germany
    > > HRB 150060 / AG München
    > > Gf Thomas Herbig
    > > http://www.reliatec.de
    > >
    > > =========================================================================
    > >
    > > Am 18.11.2013 17:16, schrieb Yama Farooq:
    >> >> Hello Friends,
    >> >>
    >> >> This is the first time i am trying to use javascript to do a simple
    >> >> calculation.
    >> >>
    >> >> I want to access the values from two field do calcualtion and save it
    >> >> into
    >> >> other input.
    >> >>
    >> >> The javascript is not running and after looking on the code using
    >> >> developer
    >> >> tools IE i found out the code has been commented using
    >> >>
    >> >> Here is the steps i followed.
    >> >>
    >> >> 1-
    >> >> Volume of blood donation in the next 4 months
    >> >>
    >> >> 2- Systemic antibiotics
    >> >>
    >> >> 3- Volume of blood to be obtained
    >> >>
    >> >> on the rightText box i have my code which
    >> >>
    >> >>
    >> >> > >> src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">> >> lang="Javascript">jQuery(document).ready(function($) {
    >> >> var v1, v2, v3;
    >> >> v1 = $("#cal_v1").parent().parent().find("input");
    >> >> v2 = $("#cal_v2").parent().parent().find("input");
    >> >> var calcel = $("#cal_rec").parent().parent().find("input");
    >> >> var res = 450 - (v1 + v2);
    >> >> cal_res.attr("readonly", true);
    >> >> calcel.value(res);
    >> >> calcel.change();
    >> >> }
    >> >>
    >> >>
    >> >>
    >> >> Thanks in advance
    > >
    > >
  • yfarooqyfarooq Posts: 41
    Hi Christian,
    Thank you very much for replay.
    there were some other errors with my code and i did implement the changes you suggested , But i am not sure why openclinica is commenting the script section.
    Any idea guys.
    here is my code :


    (document).ready(function($) {
    console.log("document.ready is started");
    var v1, v2;
    v1 = $("#cal_v1").parent().parent().find("input");
    v2 = $("#cal_v2").parent().parent().find("input");
    var calcel = $("#cal_rec");
    calcel.attr("readonly", true);
    var res = 450 - (v1.value() + v2.value());
    console.log("value of res = "+res);
    calcel.value = res;
    calcel.change();
    console.log("closing document.ready");
    });

    On Mon, Nov 18, 2013 at 10:12 PM, Christian Hänsel wrote:
    Hi Yama Farooq
    I can't help you with the comment out code but there are some little
    bugs in your JavaScript code.
    1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    2. cal_res.attr("readonly", true); => calcel.attr("readonly", true);
    3. var res = 450 - (v1 + v2); => var res = 450 - (v1.value()
    + v2.value());
    Regards,
    Christian
    ------------------------------------------------------------------------
    Dipl.-Inf. Christian Hänsel
    IT / Software Developer
    Tel.: +49-(0)89-5526189-16
    Fax : +49-(0)89-5526189-55
    E-Mail: [email protected]
    ReliaTec GmbH
    Schleissheimer Str. 37
    85748 Garching Germany
    HRB 150060 / AG München
    Gf Thomas Herbig
    http://www.reliatec.de
    =========================================================================
    Am 18.11.2013 17:16, schrieb Yama Farooq:
    > Hello Friends,
    >
    > This is the first time i am trying to use javascript to do a simple
    > calculation.
    >
    > I want to access the values from two field do calcualtion and save it into
    > other input.
    >
    > The javascript is not running and after looking on the code using developer
    > tools IE i found out the code has been commented using
    >
    > Here is the steps i followed.
    >
    > 1-
    > Volume of blood donation in the next 4 months
    >
    > 2- Systemic antibiotics
    >
    > 3- Volume of blood to be obtained
    >
    > on the rightText box i have my code which
    >
    >
    > lang="Javascript">jQuery(document).ready(function($) {
    > var v1, v2, v3;
    > v1 = $("#cal_v1").parent().parent().find("input");
    > v2 = $("#cal_v2").parent().parent().find("input");
    > var calcel = $("#cal_rec").parent().parent().find("input");
    > var res = 450 - (v1 + v2);
    > cal_res.attr("readonly", true);
    > calcel.value(res);
    > calcel.change();
    > }
    >
    >
    >
    > Thanks in advance
  • yfarooqyfarooq Posts: 41
    Hi Gerben,
    Thank you very much for reply, really appreciate your help.
    I run your code and everything looks fine, however the value in "cal_res" is missing.
    here is the code


    $.noConflict();
    jQuery(document).ready(function($) {
    var v1 = $(""#cal_v1"").parent().parent().find(""input"");
    var v2 = $(""#cal_v2"").parent().parent().find(""input"");
    var calcel = $(""#cal_res"").parent().parent().find(""input"");
    function doTheCalc(){
    var res = 450 - v1.val() - v2.val();
    // only write the result if it is different from what is already there
    if (res != calcel.val()){
    calcel.attr(""readonly"", true);
    calcel.val(res);
    calcel.change();
    }
    };
    // calculate if anything changes in v1
    v1.keyup(function(){
    doTheCalc();
    });
    // calculate if anything changes in v2
    v2.keyup(function(){
    doTheCalc();
    });
    // calculate when the page is loaded
    doTheCalc();
    })

    Any suggestion ?
    Thanks
    Yama
    On Tue, Nov 19, 2013 at 10:09 AM, Yama Farooq wrote:
    Hi Christian,
    Thank you very much for replay.
    there were some other errors with my code and i did implement the changes you suggested , But i am not sure why openclinica is commenting the script section.
    Any idea guys.
    here is my code :


    (document).ready(function($) {
    console.log("document.ready is started");
    var v1, v2;
    v1 = $("#cal_v1").parent().parent().find("input");
    v2 = $("#cal_v2").parent().parent().find("input");
    var calcel = $("#cal_rec");
    calcel.attr("readonly", true);
    var res = 450 - (v1.value() + v2.value());
    console.log("value of res = "+res);
    calcel.value = res;
    calcel.change();
    console.log("closing document.ready");
    });

    On Mon, Nov 18, 2013 at 10:12 PM, Christian Hänsel wrote:
    Hi Yama Farooq
    I can't help you with the comment out code but there are some little
    bugs in your JavaScript code.
    1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    2. cal_res.attr("readonly", true); => calcel.attr("readonly", true);
    3. var res = 450 - (v1 + v2); => var res = 450 - (v1.value()
    + v2.value());
    Regards,
    Christian
    ------------------------------------------------------------------------
    Dipl.-Inf. Christian Hänsel
    IT / Software Developer
    Tel.: +49-(0)89-5526189-16
    Fax : +49-(0)89-5526189-55
    E-Mail: [email protected]
    ReliaTec GmbH
    Schleissheimer Str. 37
    85748 Garching Germany
    HRB 150060 / AG München
    Gf Thomas Herbig
    http://www.reliatec.de
    =========================================================================
    Am 18.11.2013 17:16, schrieb Yama Farooq:
    > Hello Friends,
    >
    > This is the first time i am trying to use javascript to do a simple
    > calculation.
    >
    > I want to access the values from two field do calcualtion and save it into
    > other input.
    >
    > The javascript is not running and after looking on the code using developer
    > tools IE i found out the code has been commented using
    >
    > Here is the steps i followed.
    >
    > 1-
    > Volume of blood donation in the next 4 months
    >
    > 2- Systemic antibiotics
    >
    > 3- Volume of blood to be obtained
    >
    > on the rightText box i have my code which
    >
    >
    > lang="Javascript">jQuery(document).ready(function($) {
    > var v1, v2, v3;
    > v1 = $("#cal_v1").parent().parent().find("input");
    > v2 = $("#cal_v2").parent().parent().find("input");
    > var calcel = $("#cal_rec").parent().parent().find("input");
    > var res = 450 - (v1 + v2);
    > cal_res.attr("readonly", true);
    > calcel.value(res);
    > calcel.change();
    > }
    >
    >
    >
    > Thanks in advance
  • GerbenRienkGerbenRienk Posts: 814 ✭✭✭
    Hello Yama,
    Please find attached the XL with which I experimented.
    Can you tell the difference(s) with your XL?
    Kind regards,
    Gerben Rienk
    > > Hi Gerben,
    > >
    > > Thank you very much for reply, really appreciate your help.
    > >
    > > I run your code and everything looks fine, however the value in "cal_res"
    > > is missing.
    > >
    > >
    > > here is the code
    > >
    > >
    > >
    > > $.noConflict();
    > > jQuery(document).ready(function($) {
    > > var v1 = $(""#cal_v1"").parent().parent().find(""input"");
    > > var v2 = $(""#cal_v2"").parent().parent().find(""input"");
    > > var calcel = $(""#cal_res"").parent().parent().find(""input"");
    > >
    > > function doTheCalc(){
    > > var res = 450 - v1.val() - v2.val();
    > > // only write the result if it is different from what is
    > > already there
    > > if (res != calcel.val()){
    > > calcel.attr(""readonly"", true);
    > > calcel.val(res);
    > > calcel.change();
    > > }
    > > };
    > > // calculate if anything changes in v1
    > > v1.keyup(function(){
    > > doTheCalc();
    > > });
    > > // calculate if anything changes in v2
    > > v2.keyup(function(){
    > > doTheCalc();
    > > });
    > > // calculate when the page is loaded
    > > doTheCalc();
    > > })
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > Any suggestion ?
    > >
    > > Thanks
    > >
    > > Yama
    > >
    > >
    > >
    > >
    > > On Tue, Nov 19, 2013 at 10:09 AM, Yama Farooq
    > > wrote:
    > >
    >> >> Hi Christian,
    >> >>
    >> >> Thank you very much for replay.
    >> >>
    >> >> there were some other errors with my code and i did implement the
    >> >> changes
    >> >> you suggested , But i am not sure why openclinica is commenting the
    >> >> script section.
    >> >>
    >> >> Any idea guys.
    >> >>
    >> >>
    >> >>
    >> >> here is my code :
    >> >>
    >> >> > >> ">
    >> >>
    >> >> (document).ready(function($) {
    >> >> console.log("document.ready is started");
    >> >> var v1, v2;
    >> >> v1 = $("#cal_v1").parent().parent().find("input");
    >> >> v2 = $("#cal_v2").parent().parent().find("input");
    >> >> var calcel = $("#cal_rec");
    >> >> calcel.attr("readonly", true);
    >> >> var res = 450 - (v1.value() + v2.value());
    >> >> console.log("value of res = "+res);
    >> >> calcel.value = res;
    >> >> calcel.change();
    >> >> console.log("closing document.ready");
    >> >> });
    >> >>
    >> >>
    >> >>
    >> >>
    >> >> On Mon, Nov 18, 2013 at 10:12 PM, Christian Hänsel
    >> >> wrote:
    >> >>
    >>> >>> Hi Yama Farooq
    >>> >>>
    >>> >>> I can't help you with the comment out code but there are some little
    >>> >>> bugs in your JavaScript code.
    >>> >>>
    >>> >>> 1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    >>> >>> 2. cal_res.attr("readonly", true); => calcel.attr("readonly",
    >>> >>> true);
    >>> >>> 3. var res = 450 - (v1 + v2); => var res = 450 -
    >>> >>> (v1.value()
    >>> >>> + v2.value());
    >>> >>>
    >>> >>> Regards,
    >>> >>> Christian
    >>> >>>
    >>> >>> ------------------------------------------------------------------------
    >>> >>>
    >>> >>> Dipl.-Inf. Christian Hänsel
    >>> >>>
    >>> >>> IT / Software Developer
    >>> >>>
    >>> >>> Tel.: +49-(0)89-5526189-16
    >>> >>> Fax : +49-(0)89-5526189-55
    >>> >>> E-Mail: [email protected]
    >>> >>>
    >>> >>> ReliaTec GmbH
    >>> >>> Schleissheimer Str. 37
    >>> >>> 85748 Garching Germany
    >>> >>> HRB 150060 / AG München
    >>> >>> Gf Thomas Herbig
    >>> >>> http://www.reliatec.de
    >>> >>>
    >>> >>> =========================================================================
    >>> >>>
    >>> >>> Am 18.11.2013 17:16, schrieb Yama Farooq:
    >>>> >>> > Hello Friends,
    >>>> >>> >
    >>>> >>> > This is the first time i am trying to use javascript to do a simple
    >>>> >>> > calculation.
    >>>> >>> >
    >>>> >>> > I want to access the values from two field do calcualtion and save it
    >>> >>> into
    >>>> >>> > other input.
    >>>> >>> >
    >>>> >>> > The javascript is not running and after looking on the code using
    >>> >>> developer
    >>>> >>> > tools IE i found out the code has been commented using
    >>>> >>> >
    >>>> >>> > Here is the steps i followed.
    >>>> >>> >
    >>>> >>> > 1-
    >>>> >>> > Volume of blood donation in the next 4
    >>> >>> months

    >>>> >>> >
    >>>> >>> > 2- Systemic antibiotics
    >>>> >>> >
    >>>> >>> > 3- Volume of blood to be obtained
    >>>> >>> >
    >>>> >>> > on the rightText box i have my code which
    >>>> >>> >
    >>>> >>> >
    >>>> >>> > >> >>> src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
    >>> >>> ">>>> >>> > lang="Javascript">jQuery(document).ready(function($) {
    >>>> >>> > var v1, v2, v3;
    >>>> >>> > v1 = $("#cal_v1").parent().parent().find("input");
    >>>> >>> > v2 = $("#cal_v2").parent().parent().find("input");
    >>>> >>> > var calcel = $("#cal_rec").parent().parent().find("input");
    >>>> >>> > var res = 450 - (v1 + v2);
    >>>> >>> > cal_res.attr("readonly", true);
    >>>> >>> > calcel.value(res);
    >>>> >>> > calcel.change();
    >>>> >>> > }
    >>>> >>> >
    >>>> >>> >
    >>>> >>> >
    >>>> >>> > Thanks in advance
    >>> >>>
    >>> >>>
  • yfarooqyfarooq Posts: 41
    Hello Gerben,
    Thank you very much for all efforts. To make sure there is not problem with my CRF I upload the CRF you sent me and the value is missing. Please find attached screenshot.
    Thank you very much
    Yama
    On Tue, Nov 19, 2013 at 11:55 AM, Gerben Rienk wrote:
    Hello Yama,
    Please find attached the XL with which I experimented.
    Can you tell the difference(s) with your XL?
    Kind regards,
    Gerben Rienk
    > Hi Gerben,
    >
    > Thank you very much for reply, really appreciate your help.
    >
    > I run your code and everything looks fine, however the value in "cal_res"
    > is missing.
    >
    >
    > here is the code
    >
    >
    >
    > $.noConflict();
    > jQuery(document).ready(function($) {
    > var v1 = $(""#cal_v1"").parent().parent().find(""input"");
    > var v2 = $(""#cal_v2"").parent().parent().find(""input"");
    > var calcel = $(""#cal_res"").parent().parent().find(""input"");
    >
    > function doTheCalc(){
    > var res = 450 - v1.val() - v2.val();
    > // only write the result if it is different from what is
    > already there
    > if (res != calcel.val()){
    > calcel.attr(""readonly"", true);
    > calcel.val(res);
    > calcel.change();
    > }
    > };
    > // calculate if anything changes in v1
    > v1.keyup(function(){
    > doTheCalc();
    > });
    > // calculate if anything changes in v2
    > v2.keyup(function(){
    > doTheCalc();
    > });
    > // calculate when the page is loaded
    > doTheCalc();
    > })
    >
    >
    >
    >
    >
    >
    >
    > Any suggestion ?
    >
    > Thanks
    >
    > Yama
    >
    >
    >
    >
    > On Tue, Nov 19, 2013 at 10:09 AM, Yama Farooq
    > wrote:
    >
    >> Hi Christian,
    >>
    >> Thank you very much for replay.
    >>
    >> there were some other errors with my code and i did implement the
    >> changes
    >> you suggested , But i am not sure why openclinica is commenting the
    >> script section.
    >>
    >> Any idea guys.
    >>
    >>
    >>
    >> here is my code :
    >>
    >> > ">
    >>
    >> (document).ready(function($) {
    >> console.log("document.ready is started");
    >> var v1, v2;
    >> v1 = $("#cal_v1").parent().parent().find("input");
    >> v2 = $("#cal_v2").parent().parent().find("input");
    >> var calcel = $("#cal_rec");
    >> calcel.attr("readonly", true);
    >> var res = 450 - (v1.value() + v2.value());
    >> console.log("value of res = "+res);
    >> calcel.value = res;
    >> calcel.change();
    >> console.log("closing document.ready");
    >> });
    >>
    >>
    >>
    >>
    >> On Mon, Nov 18, 2013 at 10:12 PM, Christian Hänsel
    >> wrote:
    >>
    >>> Hi Yama Farooq
    >>>
    >>> I can't help you with the comment out code but there are some little
    >>> bugs in your JavaScript code.
    >>>
    >>> 1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    >>> 2. cal_res.attr("readonly", true); => calcel.attr("readonly",
    >>> true);
    >>> 3. var res = 450 - (v1 + v2); => var res = 450 -
    >>> (v1.value()
    >>> + v2.value());
    >>>
    >>> Regards,
    >>> Christian
    >>>
    >>> ------------------------------------------------------------------------
    >>>
    >>> Dipl.-Inf. Christian Hänsel
    >>>
    >>> IT / Software Developer
    >>>
    >>> Tel.: +49-(0)89-5526189-16
    >>> Fax : +49-(0)89-5526189-55
    >>> E-Mail: [email protected]
    >>>
    >>> ReliaTec GmbH
    >>> Schleissheimer Str. 37
    >>> 85748 Garching Germany
    >>> HRB 150060 / AG München
    >>> Gf Thomas Herbig
    >>> http://www.reliatec.de
    >>>
    >>> =========================================================================
    >>>
    >>> Am 18.11.2013 17:16, schrieb Yama Farooq:
    >>> > Hello Friends,
    >>> >
    >>> > This is the first time i am trying to use javascript to do a simple
    >>> > calculation.
    >>> >
    >>> > I want to access the values from two field do calcualtion and save it
    >>> into
    >>> > other input.
    >>> >
    >>> > The javascript is not running and after looking on the code using
    >>> developer
    >>> > tools IE i found out the code has been commented using
    >>> >
    >>> > Here is the steps i followed.
    >>> >
    >>> > 1-
    >>> > Volume of blood donation in the next 4
    >>> months

    >>> >
    >>> > 2- Systemic antibiotics
    >>> >
    >>> > 3- Volume of blood to be obtained
    >>> >
    >>> > on the rightText box i have my code which
    >>> >
    >>> >
    >>> > >> src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
    >>> ">>> > lang="Javascript">jQuery(document).ready(function($) {
    >>> > var v1, v2, v3;
    >>> > v1 = $("#cal_v1").parent().parent().find("input");
    >>> > v2 = $("#cal_v2").parent().parent().find("input");
    >>> > var calcel = $("#cal_rec").parent().parent().find("input");
    >>> > var res = 450 - (v1 + v2);
    >>> > cal_res.attr("readonly", true);
    >>> > calcel.value(res);
    >>> > calcel.change();
    >>> > }
    >>> >
    >>> >
    >>> >
    >>> > Thanks in advance
    >>>
    >>>
  • yfarooqyfarooq Posts: 41
    Dear Gerben,
    Thank you very much for help. your code is working fine, the problem was with Jquery, We are using OC 3.1.3 .
    solution : include
    Best Regards,
    Yama
    On Tue, Nov 19, 2013 at 12:15 PM, Yama Farooq wrote:
    Hello Gerben,
    Thank you very much for all efforts. To make sure there is not problem with my CRF I upload the CRF you sent me and the value is missing. Please find attached screenshot.
    Thank you very much
    Yama
    On Tue, Nov 19, 2013 at 11:55 AM, Gerben Rienk wrote:
    Hello Yama,
    Please find attached the XL with which I experimented.
    Can you tell the difference(s) with your XL?
    Kind regards,
    Gerben Rienk
    > Hi Gerben,
    >
    > Thank you very much for reply, really appreciate your help.
    >
    > I run your code and everything looks fine, however the value in "cal_res"
    > is missing.
    >
    >
    > here is the code
    >
    >
    >
    > $.noConflict();
    > jQuery(document).ready(function($) {
    > var v1 = $(""#cal_v1"").parent().parent().find(""input"");
    > var v2 = $(""#cal_v2"").parent().parent().find(""input"");
    > var calcel = $(""#cal_res"").parent().parent().find(""input"");
    >
    > function doTheCalc(){
    > var res = 450 - v1.val() - v2.val();
    > // only write the result if it is different from what is
    > already there
    > if (res != calcel.val()){
    > calcel.attr(""readonly"", true);
    > calcel.val(res);
    > calcel.change();
    > }
    > };
    > // calculate if anything changes in v1
    > v1.keyup(function(){
    > doTheCalc();
    > });
    > // calculate if anything changes in v2
    > v2.keyup(function(){
    > doTheCalc();
    > });
    > // calculate when the page is loaded
    > doTheCalc();
    > })
    >
    >
    >
    >
    >
    >
    >
    > Any suggestion ?
    >
    > Thanks
    >
    > Yama
    >
    >
    >
    >
    > On Tue, Nov 19, 2013 at 10:09 AM, Yama Farooq
    > wrote:
    >
    >> Hi Christian,
    >>
    >> Thank you very much for replay.
    >>
    >> there were some other errors with my code and i did implement the
    >> changes
    >> you suggested , But i am not sure why openclinica is commenting the
    >> script section.
    >>
    >> Any idea guys.
    >>
    >>
    >>
    >> here is my code :
    >>
    >> > ">
    >>
    >> (document).ready(function($) {
    >> console.log("document.ready is started");
    >> var v1, v2;
    >> v1 = $("#cal_v1").parent().parent().find("input");
    >> v2 = $("#cal_v2").parent().parent().find("input");
    >> var calcel = $("#cal_rec");
    >> calcel.attr("readonly", true);
    >> var res = 450 - (v1.value() + v2.value());
    >> console.log("value of res = "+res);
    >> calcel.value = res;
    >> calcel.change();
    >> console.log("closing document.ready");
    >> });
    >>
    >>
    >>
    >>
    >> On Mon, Nov 18, 2013 at 10:12 PM, Christian Hänsel
    >> wrote:
    >>
    >>> Hi Yama Farooq
    >>>
    >>> I can't help you with the comment out code but there are some little
    >>> bugs in your JavaScript code.
    >>>
    >>> 1. var calcel = $("#cal_rec")... => var calcel = $("#cal_res").
    >>> 2. cal_res.attr("readonly", true); => calcel.attr("readonly",
    >>> true);
    >>> 3. var res = 450 - (v1 + v2); => var res = 450 -
    >>> (v1.value()
    >>> + v2.value());
    >>>
    >>> Regards,
    >>> Christian
    >>>
    >>> ------------------------------------------------------------------------
    >>>
    >>> Dipl.-Inf. Christian Hänsel
    >>>
    >>> IT / Software Developer
    >>>
    >>> Tel.: +49-(0)89-5526189-16
    >>> Fax : +49-(0)89-5526189-55
    >>> E-Mail: [email protected]
    >>>
    >>> ReliaTec GmbH
    >>> Schleissheimer Str. 37
    >>> 85748 Garching Germany
    >>> HRB 150060 / AG München
    >>> Gf Thomas Herbig
    >>> http://www.reliatec.de
    >>>
    >>> =========================================================================
    >>>
    >>> Am 18.11.2013 17:16, schrieb Yama Farooq:
    >>> > Hello Friends,
    >>> >
    >>> > This is the first time i am trying to use javascript to do a simple
    >>> > calculation.
    >>> >
    >>> > I want to access the values from two field do calcualtion and save it
    >>> into
    >>> > other input.
    >>> >
    >>> > The javascript is not running and after looking on the code using
    >>> developer
    >>> > tools IE i found out the code has been commented using
    >>> >
    >>> > Here is the steps i followed.
    >>> >
    >>> > 1-
    >>> > Volume of blood donation in the next 4
    >>> months

    >>> >
    >>> > 2- Systemic antibiotics
    >>> >
    >>> > 3- Volume of blood to be obtained
    >>> >
    >>> > on the rightText box i have my code which
    >>> >
    >>> >
    >>> > >> src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
    >>> ">>> > lang="Javascript">jQuery(document).ready(function($) {
    >>> > var v1, v2, v3;
    >>> > v1 = $("#cal_v1").parent().parent().find("input");
    >>> > v2 = $("#cal_v2").parent().parent().find("input");
    >>> > var calcel = $("#cal_rec").parent().parent().find("input");
    >>> > var res = 450 - (v1 + v2);
    >>> > cal_res.attr("readonly", true);
    >>> > calcel.value(res);
    >>> > calcel.change();
    >>> > }
    >>> >
    >>> >
    >>> >
    >>> > Thanks in advance
    >>>
    >>>
This discussion has been closed.