1

I am creating a custom list. I removed the ribbon at the new form because it was not designed as the site and was ugly. Instead of it I would like to add a cancel button to the top of the page, same as at the bottom by default becuase the form is quite long. How can I do that by adding javascript?

2
  • are you using Infopath? nintex? clean Javascript? can you add more details about your form ?
    – Mike
    Feb 13, 2018 at 17:30
  • Using clear Javascript by adding script editor to the site.
    – Nefri
    Feb 14, 2018 at 8:29

1 Answer 1

0

There are many ways to do this. But couple of easiest would be:

  1. Create a 'NewItem' form using designer(It gives you a default Save & cancel button both top and bottom)
  2. Open the newitem page in seperate window and Click Gear icon ->Choose 'edit page' and add below script inside Content Editor Webpart(CWEP)

`

<html>
  <head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
  <script>
   $('table.ms-formtable').before("<a href='yoururl' style='padding:10px;float:right;background-color:red;color:#fff;border-radius:5px;'>Cancel</a>")
  </script>
</body>
</html>
2
  • Please don't edit content editors inside SharePoint Designer, this is a horrible practice as it don't let the normal user access the code. you have 2 better practices that are 1.- Create an html file and store in site assets, and then add it to your content link in the content editor web part properties 2.- place your code in an script editor
    – Mike
    Feb 13, 2018 at 17:27
  • Same thoughts @Erin. If you read my answer correctly I did not say 'Edit' in designer. I said create a new itempage using designer or edit the newitem page in browser(I believe if you know SharePoint using ~gear~ icon is only possible via browser). So understand the answer before you vote for it. You are always allowed to answer on your own.. Feb 13, 2018 at 17:32

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.