javascript - Show sections based on value of Check box in jQuery (SharePoint 2010) -
i trying use jquery show section if user selects checkbox in sharepoint form. have had success doing button , simple checkbox 1 value show blog post http://akanoongo.blogspot.com/2008/04/how-to-hide-fields-in-sharepoint-list.html, struggling if select multiple values.
<script type="text/javascript" src="/siteassets/libraries/jquery-1.10.2.min.js"></script> <script> $(document).ready(function(){ $("nobr:contains('desk calendars')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('calendar refills')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('spiral bound')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('wall calendars')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('misc. calendars')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('franklin covey')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('comments')").parent('h3').parent('td').parent('tr').hide(); $("nobr:contains('retention policy')").parent('h3').parent('td').parent('tr').hide(); }); </script>
it appear value needs if statement contains value not click function. not sure though.
$("input[title$='showfields']").click(function()
basically if select wall calendars should show jsut wall calendar if wall , desk, should toggle them both.
any guidance fantastic. thank you!
edit: change answer based on comment below
to want i'll use library created called sharepointplus (please load jquery , sharepointplus in page). javascript code like:
// hide rows default $sp().formfields("desk calendars,calendar refills,spiral bound,wall calendars,misc. calendars,franklin covey,comments,retention policy").row().hide(); // add trigger when click checkbox $sp().formfields("calendar type").elem().on('click', function(event) { // value of checkbox found "title" attribute parent // if it's checked, show row, if it's not hide $sp().formfields($(this).parent().attr("title")).row().toggle(this.checked) })
Comments
Post a Comment