0

I am new to Sharepoint Online and was trying to insert data to sharepoint list from sharepoint page containing cotent editor web part but I guess there is some problemwith my code or something which is making web part uneditable after that.

Below is my code:

HTML:

<html>
<head>
    <script type="text/javascript" src="login_javascript.js"></script>
</head>
<body>
    <clocform>
        Name:<input type="text" name="name" id="name"><br>
        Email:<input type="email" name="email" id="email"><br>
        Password:<input type="password" name="password" id="password"><br>
        <input type="button" name="submit" value="Submit" onclick="loginSubmit()">
    </clocform>

</body>

Javascript:

    function loginSubmit(){
alert("Form submitted");
var context=SP.ClientContext.get_current();
var listTitle="LoginForm1";
var login_form_list=context.get_web().get_lists().getByTitle(listTitle);
var ListItemCreationInformation=new SP.ListItemCreationInformation();
var listItem=login_form_list.addItem(ListItemCreationInformation);

var name=document.getElementById("name").value;
var email=document.getElementById("email").value;
var password=document.getElementById("password").value;
listItem.set_item('Person',name);
listItem.set_item('Email',email);
listItem.set_item('Password',password);
listItem.update();  
context.load(listItem);  
context.executeQueryAsync(AddListItemSucceeded, AddListItemFailed);  
}  

function AddListItemSucceeded()  
{  
    alert("added");
    //retriveListItem();  
}  

function AddListItemFailed(sender, args)  
{  
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());  
}  
1

The Content Editor webpart is rendered in the BODY of a SharePoint page, therefore your code should not have HTML, Body, or HEAD elements. In addition, clocform is not a supported element.

You will likely need to delete this webpart from the page and recreate it. If the webpart delete controls are also broken, you can append a ?contents=1 to the end of the url, this will bring up a list of webparts that are on the page, rather than rendering them, from there you can delete the webpart, then return to the rendered page to Edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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