warnings and messages in the CRF

Hi,
I found on Trial data solutions how to create a message ( to appear if one of the radios were selected but I'm not managing to apply it to a single-select field. I want a warning to appear if 'no' was selected (from a single select menu) for a Inc criteria (that is put in the Right Items text). Can anyone help me?

Comments

  • haenselhaensel Posts: 577 ✭✭
    Hi
    It might help if you post your current (not working) solution.

    Regards,
    Christian
  • haenselhaensel Posts: 577 ✭✭
    edited November 2017
    In general a single-select field should be handled similar to a text-field. You can get the current value using


    var selectList = ("#SomeID").parent().parent().find("input");
    var selectedValue = selectList.val();


    The selectedValue is the value from the option value attribute.

    <select id='selectID'> <option value="" selected="" style="">Select</option> <option value="1" style="">Text1</option> <option value="2" style="">Text2</option> <option value="3" style="">Text3</option> <option value="4" style="">Text4</option> </select>
  • Michelle_DMichelle_D Posts: 100


    I found this for Text fields:
     

    // for OC versions before 3.1.4, use jquery-1.3.2.min.js !

    $.noConflict();
    jQuery(document).ready(function($) {
    var fieldToCheck = $("#MessageDiv").parent().parent().find("input");

    function setMessage(){
    var valueToCheck = fieldToCheck.val();
    if (valueToCheck && (valueToCheck > 5 || valueToCheck < 2)){
    $("#MessageDiv").html("Normal range is between 2 and 5!");
    }
    else {
    $("#MessageDiv").html("");
    };
    };
    fieldToCheck.keyup(function(){
    setMessage();
    });
    setMessage();
    })


    it didn't work on single select. Perhaps I have to write something else instead of "fieldToCheck'
  • GerbenRienkGerbenRienk Posts: 792 ✭✭✭
    Hi Michelle,
    The type of a single-select is in fact "select" ;-)
    So you can change $("#MessageDiv").parent().parent().find("input") into
    $("#MessageDiv").parent().parent().find("select")
    Kind regards,
    Gerben Rienk
  • Michelle_DMichelle_D Posts: 100
    Hi,thanks for that, but I obviously still have to change something.
    this is what I have:
     

    // for OC versions before 3.1.4, use jquery-1.3.2.min.js !

    $.noConflict();
    jQuery(document).ready(function($) {
    var fieldToCheck = $("#MessageDiv").parent().parent().find("select");

    function setMessage(){
    var valueToCheck = fieldToCheck.val();
    if (valueToCheck && (valueToCheck = 0)){
    $("#MessageDiv").html("Please note that at least ONE question (either A or B) MUST be ‘Yes’ for study eligibility.");
    }
    else {
    $("#MessageDiv").html("");
    };
    };
    fieldToCheck.keyup(function(){
    setMessage();
    });
    setMessage();
    })



    maybe I shouldn't be writing 'fieldToCheck'.
  • Michelle_DMichelle_D Posts: 100
    the smiley that came up should be a B!
Sign In or Register to comment.