Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Jquery show/hide fields with change function

$
0
0

Hello,

I'm seeing a strange behavior in my jquery. 

EXAMPLE 1: The jquery in Example 1 executes just fine when there is only one element to show or hide.

EXAMPLE 2: But, if I have two elements to show or hide, as in Example 2, only the first element is shown or hidden.  The 2nd, 3rd, etc. don't show/hide.  Any ideas?

EXAMPLE 1:

$("select[title='Change Borrower']").change(function()
   { selectValue = $(this).val();

    if(selectValue == "Yes")
     
    $('td.ms-formlabel:contains("Borrower Change")').parent().show();
   }); 

  $("select[title='Change Borrower']").change(function()
   { selectValue = $(this).val();

    if(selectValue == "No")
     
    $('td.ms-formlabel:contains("Borrower Change")').parent().hide();
   });   

EXAMPLE 2

$("select[title='Change Primary']").change(function()
   { selectValue = $(this).val();

    if(selectValue == "Yes")
     
    $('td.ms-formlabel:contains("Primary Current")').parent().show();//Only this one shows
    $('td.ms-formlabel:contains("Primary New")').parent().show(); //This one does not show
   }); 
   
  $("select[title='Change Primary']").change(function()
   { selectValue = $(this).val();

    if(selectValue == "No")
     
    $('td.ms-formlabel:contains("Primary Current")').parent().hide();
    $('td.ms-formlabel:contains("Primary New")').parent().hide();
   }); 


Thanks! Patti N.


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>