troubleshooting Question

DataTables Form Input issue.

Avatar of Isaac
IsaacFlag for United States of America asked on
JavaScriptMicrosoft SharePoint
3 Comments1 Solution340 ViewsLast Modified:
Hi All,

I am trying to get my page to do what's on this site (click the submit form above the table).  As you will see, it alerts data from the table.

My alert does not do the same thing.  I think it's b/c how sloppy my code is which I'm trying to figure out how to fix but no success.  Any help would be appreciated.
Here's the site and code.

$(function() {

function retrieveListItems() {
	var clientContext = new SP.ClientContext();
	var oList = clientContext.get_web().get_lists().getByTitle('ParkFundingForm');
	var camlQuery = new SP.CamlQuery();
	this.collListItem = oList.getItems(camlQuery);
        Function.createDelegate(this, this.onQuerySucceeded),
        Function.createDelegate(this, this.onQueryFailed)

var htmlTbl = "<div><button type='Submit'>Submit Form</button></div><table id='prioritize' class='display' cellspacing='0' width='100%'>";
	htmlTbl += "<thead><th>Priority Number</th><th>Title</th><th>Project Name</th><th>Project Number</th></thead>";
	htmlTbl += "<tbody>";

//var items=[];

function onQuerySucceeded(sender, args) {
	var listItemInfo = '';
	var listItemEnumerator = collListItem.getEnumerator();
	while (listItemEnumerator.moveNext()) {
		var oListItem = listItemEnumerator.get_current();
		htmlTbl += "<tr><td><input type='text' id='rowID-"+oListItem.get_item('ProjectName')+"' value="+oListItem.get_item('PriorityNumber')+"></td><td>"+oListItem.get_item('Title')+"</td><td>"+oListItem.get_item('ProjectName')+"</td><td>"+oListItem.get_item('ProjectNumber')+"</td></tr>";
	htmlTbl += "</tbody></table>";
		var table = $('#prioritize').DataTable();
    $('button').click( function() {
        var data = table.$('input').serialize();
            "The following data would have been submitted to the server: \n\n"+
            data.substr( 1, 120 )+'nothing...'
        return false;
    } );


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

/*$(document).ready(function() {
Analyst programmer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros