One can do lots of fancy stuff using JQuery and SharePoint. Consider a scenario where a list field visibility needs to be changed based on a selection of drop down value.
The list field visibility can be changed on SharePoint NewForm.aspx or EditForm.aspx by adding the following script either directly in the page by using SharePoint designer or pasting it in a Content Editor webpart.
Here the field Location is shown/hidden based on the value selected in Drop down field Language. A Change event is attached to the Language field (drop down). Whenever, the selection in the drop down is changed, the event is fired. Value of the selected item is retrieved and then it is compared to a hradcoded value and based on that visibility of Location field is changed.
The list field visibility can be changed on SharePoint NewForm.aspx or EditForm.aspx by adding the following script either directly in the page by using SharePoint designer or pasting it in a Content Editor webpart.
<script src="http://sp2010:90/JQuery/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
var languageField = $("select[title='Language']");
languageField .change(function() {
var locationField = $("input[title=Location]");
var val = $(this).val();
if(val == "B")
{
locationField.parent().parent().parent().hide();
}
else
{
locationField.parent().parent().parent().show();
}
});
</script>
Here the field Location is shown/hidden based on the value selected in Drop down field Language. A Change event is attached to the Language field (drop down). Whenever, the selection in the drop down is changed, the event is fired. Value of the selected item is retrieved and then it is compared to a hradcoded value and based on that visibility of Location field is changed.