1

I have a sharepoint list which contains a drop down of the values , Immediate , Hire , Specific

I have another column Grace Period which is a numeric

When the drop down column Immediate is selected the Grace Period should be a fixed zero

When the drop down Hire is selected the user can add Grace Period, but it should not be zero

When the drop down is Specific the user can add either zero or any number

How can this be achieved.

Can column validation be used. I am confused about the formula that can be used

Any help is highly appreciated

2
  • Do you want the Grace Period to appear in forms? And user can change the value? Jan 23, 2014 at 9:28
  • Yes, I want it to appear in the forms and user can change values. But in case of Immediate, it should be set to 0. Jan 23, 2014 at 10:15

1 Answer 1

1

You can do it with a bit of JavaScript.. But that is messy and its not good to include JavaScript in default List Forms..

Since you have SharePoint Enterprise, I will suggest you to edit the List Forms in InfoPath and using Rules set the value of Grace Period on value change of drop down.

Automatically Set Field Value in InfoPath

UPDATE

Since you have Standard Version, InfoPath forms will not be available.. You can try doing it from JavaScript

// Use drop down field title below
$("input[title='title_of_the_field']").change(function() {
   setGracePeriod(this.value);
});

function setGracePeriod(dropdownValue)
{
  switch(dropdownValue)
  {
      case "Immediate":
      //Here you should use Grace Period field title
      $("input[title='title_of_the_field']").val('0');
      break;
  }
}

PS: You should reference JQuery Library in Master Page

Reference

How do I get the value of a SharePoint:FormField with javascript?

5
  • Oops sorry , I have SharePoint Standard. Isnt there any way that it can be done Jan 23, 2014 at 11:28
  • Please check the update Jan 23, 2014 at 11:36
  • Thank you for taking your time, I tried adding the code you sent via content editor webpart. but it doesn't seem to work. Am I missing something Jan 24, 2014 at 5:09
  • Have you reference JQuery Library in Master Page or Right before your Script within Content Editor Web Part ? Jan 24, 2014 at 13:29
  • i downloaded jquery 1.8.0 min.js , added it to the style library and provided the following code <script src="/Style%20Library/jquery-1.8.0.min.js" type="text/javascript"></script> <script type="text/javascript"> $("input[title='Initial Training']").change(function() { setGracePeriod(this.value); }); function setGracePeriod(dropdownValue) { switch(dropdownValue) { case "Immediate": $("input[title='Grace Period']").val('0'); break; } } </script> Jan 27, 2014 at 6:35

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.