Widget:TwoColumnDataTable

This widget appends data to a two column data table via a web form. It currently only writes a simple table with one data point. Need to work on code to allow it to append a current data table.   var sb = new Object; function weDataSave { var fields = Array('Variable 1', 'Variable 2'); var required = Array('weOne', 'weTwo'); var reg = ' '; var fail = '';

for (var i=0; i<required.length; i++){ var e = document.getElementById(required[i]); if (e && e.value == '') { fail += 'Please complete ' + fields[i] + '\n'; }     if (i == (required.length-1)){ reg += e.value ; }else{ reg += e.value + ' '; }   }  reg += '  ';

if (fail) { alert(fail); return false; }

/* $('table').append(reg); */ var weAPI = wgServer + '/api.php'; // load the wikitext and an edit token $.ajax({     type: 'POST',      url: weAPI,      data: {        action: 'query',        prop: 'info|revisions',        intoken: 'edit',        titles: wgPageName,        rvprop: 'content',        format: 'json'      },      error: function(hdr, stat, err) {        alert("Unable to fetch data page!\n" + stat);      },      success: function (d) {        for (var pg in d.query.pages) {          var page = d.query.pages[pg];          var token = page.edittoken;          var wikitext = page.revisions[0]['*'];        }        $.ajax({ type: 'POST', url: weAPI, data: { action: 'edit', title: wgPageName, summary: 'Added data row(s)', text: wikitext.replace(' ', " 9  99  \n "), token: token, format: 'json' },         error: function(hdr, stat, err) { alert("Unable to save data!\n" + stat); },         success: function (d) { // lazy way to redraw, reset window.location = wgServer + '/' + wgPageName; }       });      }    });

$('#wpTextbox1').val(reg); $('#wpSave').val(sb); return true; }

$(function { while (typeof $ == 'undefined') ;    /* uncheck the checkboxes, and hide their labels */    $('#wpMinoredit, #wpWatchthis').attr('checked', '').hide.next.hide;    $('#wpSummaryLabel, #wpSummary, #fckTools, #toolbar, #wpTextbox1, #editpage-copywarn, #wpPreview, #wpDiff').hide;    $('.editHelp').hide;    $('#firstHeading').text('Two Column Data Table');    $('#wpSave').attr('title', 'Add Data');    sb = $('#wpSave').val;    $('#wpSave').val( 'Add Data').bind('click', function { return weDataSave; });    /* document.getElementById('editform').onsubmit = function {return weData;}; */

var f = ' '; var myForm = document.createElement('div'); myForm.id = 'myForm'; myForm.innerHTML = f;   document.getElementById('contentSub').appendChild(myForm); });