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?
1 Answer
There are many ways to do this. But couple of easiest would be:
- Create a 'NewItem' form using designer(It gives you a default Save & cancel button both top and bottom)
- Open the newitem page in seperate window and
Click Gear icon ->Choose 'edit page'
and add below script insideContent 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>
-
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– MikeFeb 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