locked
Changing a radio button using a IF Statement RRS feed

  • Question

  • Hi,

    I am trying to change the radio button value to YES when a date is on or before another date.

    I have used the following code on the OnChange event

    if (crmForm.all.kf_casecloseddate.DataValue < kf_targetdate.DataValue)

    {
    crmForm.all.kf_targetdatemet.DataValue = 1;
    crmForm.all.kf_targetdatemet = true;
    }

    Could someone please assist

    Thank you

    Tuesday, December 11, 2012 10:05 AM

Answers

  • Hi,

    You have put a clause else, like this:

        var closedDate = Date.parse(crmForm.all.kf_casecloseddate.DataValue);
        var targetDate = Date.parse(crmForm.all.kf_targetdate.DataValue);
    
        if(closedDate <= targetDate ) {
            crmForm.all.kf_targetdatemet.DataValue = true;
        }
        else{
            crmForm.all.kf_targetdatemet.DataValue = false;
        }

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.



    Pedro Azevedo Crm Specialist 4.0\2011

    • Proposed as answer by Azevedo PedroMVP Thursday, December 13, 2012 3:02 PM
    • Marked as answer by Kully88 Friday, February 15, 2013 3:24 PM
    Thursday, December 13, 2012 3:02 PM

All replies

  • Hi,

    Try this code:

        var closedDate = Date.parse(crmForm.all.kf_casecloseddate.DataValue);
        var targetDate = Date.parse(crmForm.all.kf_targetdate.DataValue);
    
        if(closedDate <= targetDate ) {
            crmForm.all.kf_targetdatemet.DataValue = true;
        }

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.


    Pedro Azevedo Crm Specialist 4.0\2011

    • Proposed as answer by Azevedo PedroMVP Tuesday, December 11, 2012 10:30 AM
    • Marked as answer by Kully88 Wednesday, December 12, 2012 9:52 AM
    • Unmarked as answer by Kully88 Thursday, December 13, 2012 1:15 PM
    Tuesday, December 11, 2012 10:30 AM
  • Thank you very much Azevedo that has worked like a treat.

    Thanks again

    Wednesday, December 12, 2012 9:53 AM
  • Hi Azevedo,

    Thank you for you response, I did initially think it worked as required.

    It does work in the first instance so if the completed date is put in it checks if before or on the target date and changes the radio button, but if somone put the wrong date first (e.g before the target date) this changes the radio button to yes but then if a user goes back in and changes the date to after the target date the radio button does not change back to No.

    Please could you assist.

    Thank you

    Thursday, December 13, 2012 1:29 PM
  • Hi,

    You have put a clause else, like this:

        var closedDate = Date.parse(crmForm.all.kf_casecloseddate.DataValue);
        var targetDate = Date.parse(crmForm.all.kf_targetdate.DataValue);
    
        if(closedDate <= targetDate ) {
            crmForm.all.kf_targetdatemet.DataValue = true;
        }
        else{
            crmForm.all.kf_targetdatemet.DataValue = false;
        }

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.



    Pedro Azevedo Crm Specialist 4.0\2011

    • Proposed as answer by Azevedo PedroMVP Thursday, December 13, 2012 3:02 PM
    • Marked as answer by Kully88 Friday, February 15, 2013 3:24 PM
    Thursday, December 13, 2012 3:02 PM