I have the information below working, however if I have more than 3 value pairs it can be a long string. How do I turn the value pairs into an array? I tried to use this example but I'm not clear on how to add it. valuepairs
<table>
<tr>
<td><strong>List Item to be added</strong></td>
<td><input id="Test1" name="Test1" type="text" /></td>
<td><input id="Test2" name="Test2" type="text" /></td>
<td><input id="Test3" name="Test3" 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 IN1 = $("#Test1").val();
var IN2 = $("#Test2").val();
var IN3 = $("#Test3").val();
AddListItem(IN1, IN2, IN3);
});
});
function AddListItem(TitleField, FNField, LNField) {
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "New",
listName: "testlist",
valuepairs: [["Title", TitleField], ["FirstName", FNField], ["LastName", LNField]],
completefunc: function (xData, Status) {
alert("Data Saved! and Please check your List");
}
});
}
</script>

0 commentaires:
Enregistrer un commentaire