1

I want to create a custom list in 2010.

Requirements:

  • I have a field named "code move" , dropdownlist containg two values(yes and NO).
  • If i choose yes,some new fields should appear to fill out.

ex: 4. Is there are code move? If yes, need to fill out the below fields.

    Component :
         Type :
   New/Change : 

If no, nothing should be done.

Please suggest me how can I acheive this.

2 Answers 2

1

Samba,

If you are using simple list form and want hide/show field based on drop down list selection then add a Content Editor Web Part on NewForm.aspx and use below Java script/JQuery:
Show/Hide Columns Based on Drop Down Selection
How to Hide Fields in SharePoint Custom List With Drop Down Value
Walkthrough: Conditionally Hide Fields on SharePoint 2010 Standard List Forms using jQuery

If you have InfoPath form or customizing list form in InfoPath Designer then use conditional formatting to hide/show field as shown in:
SharePoint and Infopath 2010 - Conditionally Hide Form Fields

2
  • I am unable to add content editor web part in the custom list i created. i am using 2010 sp. Please let me know how to add content editor webpart.i clicked on "Add a webpart" but not able to see the content editor webpart.
    – Samba
    Sep 3, 2013 at 12:27
  • Please follow Using the Content Editor Web Part Sep 4, 2013 at 6:13
0

You can use JQuery to achieve this. Consider you have a list with fields Title (Text), Location(Text) and Language (Drop down). The following sample code can be used to hide/show Location field in NewForm.aspx or EditForm.aspx page:

<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>

The scripts attaches onchange event to dropdown list. Based on the selection it shows or hides the Location field on the page.

3
  • i am unable to insert the code in NewForm.aspx or EditForm.aspx page:the .aspx pages are not letting me to add any code.please suggest me.
    – Samba
    Sep 3, 2013 at 12:25
  • The Content Editor Webpart is present in Media and Content Cateogory when you try to add it. Also, if you have SharePoint Designer, you can Edit the forms and the code there. Sep 3, 2013 at 12:59
  • i dont see in Media and Content Cateogory.do i need to active anything in site action features?
    – Samba
    Sep 3, 2013 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.