Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

I am stucked at P33 and cannot move to the next question or the error message is not displayed where am I going wrong?

function dateDiff(date1, date2){
    var diff = {}                           // Initialisation du retour
    var tmp =   date2 - date1;
 
    tmp = Math.floor(tmp/1000);             // Nombre de secondes entre les 2 dates
    diff.sec = tmp % 60;                    // Extraction du nombre de secondes
 
    tmp = Math.floor((tmp-diff.sec)/60);    // Nombre de minutes (partie entière)
    diff.min = tmp % 60;                    // Extraction du nombre de minutes
 
    tmp = Math.floor((tmp-diff.min)/60);    // Nombre
    diff.hour = tmp % 24;                   // Extraction du nombre d'heures
     
    tmp = Math.floor((tmp-diff.hour)/24);   // Nombre de jours restants
    diff.day = tmp;
     
    return diff;
}

var dateMax = 0;

//Calcul de la date stop +14 jour :

    var dateStop = '[%ListLabel(StopDateLoop, LoopValue(Loop1))%]';
    var resultdate = dateStop.split("/");
    var next1 = new Date(resultdate[2], resultdate[1]-1,  +resultdate[0]+14);
    var newnext = (next1.toLocaleString("en-GB"));
    var resultNewdate = newnext.split("/");
    var verifMois = resultNewdate[1];
    var verifJour = resultNewdate[0];
    var datePlus14 = 0;
    var date1 = new Date(resultdate[2], resultdate[1]-1,  +resultdate[0]);
    var date2 = 0;


    if(verifMois.length<2 && verifJour.length<2)
    {
        datePlus14 = newnext.substr(0, 8);
    }
    else if(verifMois.length<2 || verifJour.length<2)
    {
        datePlus14 = newnext.substr(0, 9);
    }
    else
    {
        datePlus14 = newnext.substr(0, 10);
    }


//Verification de la date d'après :

    if(parseInt("[% ListLength(LoopListConst) %]") >= parseInt("[%LoopIteration(Loop1)+1%]"))
        {
            var dateTemp='[% ListLabel(StartDateListConst, LoopIteration(Loop1)+1) %]';
            var resultdateTemp = dateTemp.split("/");
            date2 = new Date(resultdateTemp[2], resultdateTemp[1]-1,  +resultdateTemp[0]);
            diff = dateDiff(date1, date2).day;
            if(parseInt(diff)<14)
            {
                dateMax = '[% ListLabel(StartDateListConst, LoopIteration(Loop1)+1) %]';
            }
            else
            {
                dateMax = datePlus14;
            }
        }
    else if ("[% ListLabel(verifOngoing, LoopValue(Loop1)) %]" != "1")
        {
            dateMax = datePlus14;           
        }
    else
        {
            dateMax = '[% Begin Unverified Perl
            if(VALUE("P19_date")!= "")
            {
                return VALUE("P19_date");
            }
            else
            {
                return VALUE("P18_date");
            }
            End Unverified %]';
        }
document.getElementById("Date_MaxP34e").value = dateMax ;


//Vérificaiton message d'erreur

var nb = parseInt("[% P28 %]");

if( [% Value(P3c) %] != 1 )
{
if(parseInt([% LoopIteration(Loop1) %])== nb )
    if( ( !document.getElementById("P33_1").checked &&  !document.getElementById("P33_2").checked && !document.getElementById("P33_3").checked && !document.getElementById("P33_4").checked && !document.getElementById("P33_5").checked && !document.getElementById("P33_7").checked && !document.getElementById("P33_10").checked && !document.getElementById("P33_16").checked) && "[% alkylating %]" != "1" )  || ( (!document.getElementById("P33_21").checked && !document.getElementById("P33_24").checked) && "[% antibody %]" != "1" )
    {
         strErrorMessage = '[%ListLabel(MessageErreur, 8)%]';
    }
}
asked May 11 by Ali
reshown May 21 by Walter Williams
The parentheses on this line do not match up correctly:

if( ( !document.getElementById("P33_1").checked &&  !document.getElementById("P33_2").checked && !document.getElementById("P33_3").checked && !document.getElementById("P33_4").checked && !document.getElementById("P33_5").checked && !document.getElementById("P33_7").checked && !document.getElementById("P33_10").checked && !document.getElementById("P33_16").checked) && "[% alkylating %]" != "1" )  || ( (!document.getElementById("P33_21").checked && !document.getElementById("P33_24").checked) && "[% antibody %]" != "1" ) 


You may need to add or remove some to get everything in order.  You may also want to consider breaking this up into multiple lines of code to make it easier to maintain.

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...