0

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?

  • try using an alert("test"); inside the ready function. Also, make sure the btnAdd is the right casing (not btnADD). – Mike Dec 10 '14 at 19:28
  • I will test that when I get to work. When I highlighted the syntax in Notepad++ it showed the btnAdd and btnADD as being the same. – JeremyA1 Dec 10 '14 at 20:59
  • 1
    If you aren't getting that alert, then the references to jQuery and SPS ervices are wrong. Alternatively you could hit F12 and look at the network tab of the debugger of the browser and see if those libraries result in 404 errors. Otherwise everything else looks correct. – Eric Alexander Dec 10 '14 at 21:32
  • Mike, ensuring that the name matched up for the button was the problem thanks for catching that mistake. – JeremyA1 Dec 11 '14 at 6:56
0

Change the btnADD to btnAdd then it worked

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.