pageHeader(); echo WT_JS_START; ?> function checknames(frm) { action = "action; ?>"; return true; } var numfields = fields); ?>; /** * add a row to the table of fields */ function addFields() { // get the table var tbl = document.getElementById('field_table').tBodies[0]; // create the new row var trow = document.createElement('tr'); // create the new label cell var label = document.createElement('td'); label.className='list_label'; // create a select for the user to choose the field var sel = document.createElement('select'); sel.name = 'fields['+numfields+']'; sel.rownum = numfields; sel.onchange = function() { showDate(this, this.rownum); }; // all of the field options getOtherFields() as $field=>$label) { ?> opt = document.createElement('option'); opt.value=''; opt.text=''; sel.options.add(opt); label.appendChild(sel); trow.appendChild(label); // create the new value cell var val = document.createElement('td'); val.id = 'vcell'+numfields; val.className='list_value'; var inp = document.createElement('input'); inp.name='values['+numfields+']'; inp.type='text'; inp.id='value'+numfields; inp.tabindex=numfields+1; val.appendChild(inp); trow.appendChild(val); var lastRow = tbl.lastChild.previousSibling; tbl.insertBefore(trow, lastRow.nextSibling); numfields++; } /** * add the date options selection */ function showDate(sel, row) { var type = sel.options[sel.selectedIndex].value; var pm = document.getElementById('plusminus'+row); if (!type.match("DATE$")) { // if it is not a date do not show the date if (pm) pm.parentNode.removeChild(pm); return; } // if it is a date and the plusminus is already show, then leave if (pm) return; var elm = document.getElementById('vcell'+row); var sel = document.createElement('select'); sel.id = 'plusminus'+row; sel.name = 'plusminus['+row+']'; var opt = document.createElement('option'); opt.value=''; opt.text=''; sel.appendChild(opt); opt = document.createElement('option'); opt.value=''; /* The translation strings use HTML entities, but javascript does not. See bug 687980 */ opt.text=''; sel.appendChild(opt); opt = document.createElement('option'); opt.value='5'; opt.text=''; sel.appendChild(opt); opt = document.createElement('option'); opt.value='10'; opt.text=''; sel.appendChild(opt); var spc = document.createTextNode(' '); elm.appendChild(spc); elm.appendChild(sel); }