This is something I have been struggling with for some time now. I have looked all over the internet at different forums and blogs trying to find a solution and I have finally gotten ALMOST there. I am hoping someone here can help me cross the finish line.
Here is the situation. I am developing multiple list based issue tracking solutions using the Standard edition of SharePoint 2010 for my company. I dont have access to infopath but I do have full admin control of the farm so I can install/Deploy FREE 3rd party solutions designed to make it easier to customize forms or workflows.
In short I needed a way to hide/show certain fields based on the selections of preceding fields and then make the fields required. Sounds easy but it has proven quite the challenge.
I have tried a solution that uses the sputility javascript library (found here) and it works great assuming I want to use the out of the box forms but unfortunately the business requirement involves some branding that demands the creation of custom forms and that is where sputility falls flat.
I have also tried the infowise "Smart List Pro Lite" solution (found here) but it appears to have the same limitation.
Finally I dug up a possibly solution (here) that seems to be specific to my need and using this I have managed to actually get lower fields (fied2 and field3) to hide based on a value in a field (field1) above. The only problem is I cant seem to get them to come BACK if the value in field1 is changed.
This is probably something simple but frankly I am out of my depth as I am just now starting to understand javascript. Also I apologize if technically this is a javascipt question and not a sharepoint question but I would like to post my code and see if someone can tell me what I am doing wrong:
*obviously I have modified the 3rd field type (to be a choice with an id field I could reference) but it wasn't working with the field type designated in the article either.
<script type="text/javascript" src="https://xxx.xxxxxx.xxx/Shared%20Documents/jquery-1.9.1.js"></script> <script type="text/javascript">
$(document).ready(function(){
var selected = $("select[title = 'Field1']").val();
if(selected == "Yes") {
$("select[title = 'Field2']").closest("tr").show();
$("select[title = 'Field3']").closest("tr").show();
}
else {
$("select[title = 'Field2']").closest("tr").hide();
$("select[title = 'Field3']").closest("tr").hide();
$("select[title = 'Field2']").get(0).selectedIndex = 0;
$("select[title = 'Field3']").val("");
};
$("select[title = 'Field1']").on("change", function(){
var selected = $("selected[title = 'Field1']").val();
if (selected == "Yes"){
$("select[title = 'Field2']").closest("tr").show();
$("select[title = 'Field3']").closest("tr").show();
}
else{
$("select[title = 'Field2']").closest("tr").hide();
$("select[title = 'Field3']").closest("tr").hide();
$("select[title = 'Field2']").get(0).selectedIndex = 0;
$("select[title = 'Field3']").val("");
}
});
});
</script>
As always, thank you for any help.