I created a list called testlist then I created a html within the same site with the following layout
<table>
<tr>
<td><strong>List Item to be added</strong></td>
<td><input id="txtTitle" name="txtTitle" type="text" /></td>
</tr><tr>
<td><input name="ADD" id="btnADD" type="submit" value="Add Item to List" /></td></tr>
</table>
<script src="jquery 1.11.1 stored in my library"></script>
<script src="SPServices SPServices 2014.01 stored in my library"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnAdd").click(function () {
var title = $("#txtTitle").val();
AddListItem(title);
});
});
function AddListItem(TitleField) {
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "testlist",
valuepairs: [["Title", TitleField]],
completefunc: function (xData, Status) {
alert("Data Saved! and Please check your List");
}
});
}
</script>
When I type TESTER in the box and push submit it does not enter in a new item into the list. Is there something I'm missing?

0 commentaires:
Enregistrer un commentaire