0

I am having few fields like single line of text, choice field, rich text on my customnewform.aspx of my SP 2010 SPList.
Now if I enter a value say USA on the text box, I need to set the dropdown/choice field value as Boeing if I enter the text box value as Europe then the choice field value must be set to Airbus. The choice field contains many values,like company1, company2, company3, company4 along with Boeing, Airbus etc How this can be achieved using SPutility & jQuery & JavaScript ? Am trying to use onblur function of my textbox. Will this work ? Also I need to get the validation done within the PreSaveAction function call also.

 <script language="javascript" src="/project/EASAssetsLib/jquery-
       1.6.0.min.js" type="text/javascript">
     </script><script language="javascript" 
    src="/project/EASAssetsLib/jquery.SPServices-2014.01.min.js" 
    type="text/javascript"></script><script language="javascript" 
    src="/project/EASAssetsLib/prototype.js" type="text/javascript">
    </script><script language="javascript" 
    src="/project/EASAssetsLib/SPUtility.js" type="text/javascript">
    </script>
    <script language="javascript" type="text/javascript">
     $(document).ready(function()
    {
   var txtboxfromSPUTIL = SPUtility.GetSPField('countryname').GetValue(); 
   alert(txtboxfromSPUTIL);

1 Answer 1

1

Break up your Mission in smaller tasks, you allready started with alert()

Ditch alert and learn to use F12 Developer Tools

In Chrome you can use Snippets https://stackoverflow.com/questions/10470711/chrome-developer-tools-what-is-snippets-support

That will execute any of your javascript on the current page and saves you from loading it in SharePoint

As for your tasks

  • Attach a JavaScript event handler, onblur is fine, maybe you want keyup for a better UX
  • Check what people typed
  • Set the values of the Choice field

Plenty of examples around, see the column on the right of this page for related questions & answers

Success with you Mission

4
  • I am little bit confused with this jQuery and its use in content Editor web part, like how to write this jQuery functions and where should I write. In JavaScript,we can create multiple functions and call from other functions.But here, am not sure how to call the onblur, on keyup etc etc.Sorry for telling this silly things.
    – samolpp2
    Commented Oct 13, 2015 at 14:52
  • 1
    Then learn SharePoint+jQuery first: c-sharpcorner.com/UploadFile/82b15a/… You can't fly a plane without learning to fly Commented Oct 13, 2015 at 14:54
  • Thanks for the url for starting with CSOM.Purposefully avoided this jQuery+JavaScript CSOM, because of my favourism towards writing SSOM code and FullTrust solutions.Now am forced to learn & write these client side stuff. I don't have any other option now!
    – samolpp2
    Commented Oct 13, 2015 at 14:58
  • Your requirement of changing a DropDown has got nothing to do with JSOM/CSOM.. its just plain HTML/Javascript Commented Oct 13, 2015 at 15:38

Your Answer

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

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