locked
onchange function on the field level not working after the first time RRS feed

  • Question

  • Hi

    I have my code on the field level properties ( onChange function) . It fires for the first time.That is when the user selects No from the picklist some fields shold not appear and if they select yes all should appear.
    if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue==1)
    {
    crmForm.all.new_natureofanychargeorpendingcharged_c.style.visibility='hidden';
    crmForm.all.new_natureofanychargeorpendingcharged_d.style.visibility='hidden';
    crmForm.all.new_locationwhereincidentoccured_c.style.visibility='hidden';
    crmForm.all.new_locationwhereincidentoccured_d.style.visibility='hidden';
    crmForm.all.new_dateofincident_c.style.visibility='hidden';
    crmForm.all.new_dateofincident_d.style.visibility='hidden';
    crmForm.all.new_nameaddressoflawenforcementagencyorcourto_c.style.visibility='hidden';
    crmForm.all.new_nameaddressoflawenforcementagencyorcourto_d.style.visibility='hidden';
    }
    else if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue==2)
    {
    crmForm.all.new_natureofanychargeorpendingcharged_c.style.visibility='inline';
    crmForm.all.new_natureofanychargeorpendingcharged_d.style.visibility='inline';
    crmForm.all.new_locationwhereincidentoccured_c.style.visibility='inline';
    crmForm.all.new_locationwhereincidentoccured_d.style.visibility='inline';
    crmForm.all.new_dateofincident_c.style.visibility='inline';
    crmForm.all.new_dateofincident_d.style.visibility='inline';
    crmForm.all.new_nameaddressoflawenforcementagencyorcourto_c.style.visibility='inline';
    crmForm.all.new_nameaddressoflawenforcementagencyorcourto_d.style.visibility='inline';

    }

    So what can I do to make then work every time?
    Thanks,

    Hanoi

    Tuesday, February 2, 2010 9:12 PM

Answers

  • Hi,

    You can try to chagne your code like below and see if it works

    if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue=="1")
    {
    crmForm.all.<CRMField>_d.style.display = 'none';
    crmForm.all.<CRMField>_c.style.display = 'none';

    }
    else if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue=="2")
    {
    crmForm.all.<CRMField>_d.style.display = '';
    crmForm.all.<CRMField>_c.style.display = '';
    }

     


    Mahain
    Wednesday, February 3, 2010 3:36 PM
    Moderator

All replies

  • Hi,

    Try to change your code like below


    if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue=="1")
    {
    //////////////////// code
    }
    else if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue=="2")
    {
    /////////////////// code
    }


    Mahain
    • Proposed as answer by HIMBAPModerator Wednesday, February 3, 2010 3:35 AM
    Wednesday, February 3, 2010 3:34 AM
    Moderator
  • Thanks Mahain!!!!But still not working.From the picklist if I select 'NO=1' then all the fields are gone( That is how it should be working). but if I select "YES=2' nothing showes up.
    I have published the custom entities.
    If anyone knows  a solution please help.


    Thanks,
    Hanoi
    Wednesday, February 3, 2010 2:21 PM
  • Hi, Hanoi.

    What type of field is new_haveyoueverbeenarresteddetainedorchargedf?
    Picklist or bit with picklist style?

    If bit with picklist style try to change

    crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue==1

    to

    crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue==true

    and

    crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue==2

    to

    crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue==false
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный) free counters Locations of visitors to this page
    Wednesday, February 3, 2010 2:29 PM
    Moderator
  • new_haveyoueverbeenarresteddetainedorchargedf is a picklist type field.so why is it behaving like this? Is there a work around?
    thanks,
    hanoi
    Wednesday, February 3, 2010 2:39 PM
  • Hi,

    You can try to chagne your code like below and see if it works

    if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue=="1")
    {
    crmForm.all.<CRMField>_d.style.display = 'none';
    crmForm.all.<CRMField>_c.style.display = 'none';

    }
    else if(crmForm.all.new_haveyoueverbeenarresteddetainedorchargedf.DataValue=="2")
    {
    crmForm.all.<CRMField>_d.style.display = '';
    crmForm.all.<CRMField>_c.style.display = '';
    }

     


    Mahain
    Wednesday, February 3, 2010 3:36 PM
    Moderator
  • Thanks Mahain . It is working Now. You are awesome!!!!!!

    Hanoi
    Wednesday, February 3, 2010 3:55 PM

  • Welcome HanoiABC,
    I am glad I could help !!!
    Mahain
    Thursday, February 4, 2010 4:45 AM
    Moderator