///scripts/addfields.php function addAddress() { //adds an address field //make sure it's supported if (!document.getElementById || !document.createElement) return; //add spacer row //make the new row var addressTable = document.getElementById('addresses'); var lastRow = addressTable.rows.length; var iteration = lastRow + 1; var row = addressTable.insertRow(lastRow); //add the blankrow var cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode(' ')); cell = row.insertCell(1); cell.appendChild(document.createTextNode(' ')); //add the address type row //find out which row this is lastRow++; iteration = lastRow + 1; row = addressTable.insertRow(lastRow); //add the label cell cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode('Address:')); //add the input cell cell = row.insertCell(1); //add the location selector var addressLocation = document.createElement('select'); addressLocation.name = 'addresslocation[]'; addressLocation.options[0] = new Option('Home', 'home'); addressLocation.options[1] = new Option('Work', 'work'); addressLocation.options[2] = new Option('Other', 'other'); cell.appendChild(addressLocation); //add the separator cell.appendChild(document.createTextNode(' ')); //add the priority selector var addressPriority = document.createElement('input'); addressPriority.type = 'radio'; addressPriority.name = 'addresspriority'; addressPriority.value = Math.ceil(lastRow / 7); cell.appendChild(addressPriority); //add the label cell.appendChild(document.createTextNode('Primary')); //add the first address row //find out which row this is lastRow++; iteration = lastRow + 1; row = addressTable.insertRow(lastRow); //add the label cell cell = row.insertCell(0); cell.appendChild(document.createTextNode(' ')); //add the input cell cell = row.insertCell(1); var inputBox = document.createElement('input'); inputBox.type = 'text'; /*inputBox.name = 'addressone[' + iteration + ']'; inputBox.id = 'addressone[' + iteration + ']';*/ inputBox.name = 'addressone[]'; inputBox.id = 'addressone[]'; inputBox.size = 40; inputBox.maxLength = 50; cell.appendChild(inputBox); //add the second address row //find out which row this is lastRow++; iteration = lastRow + 1; row = addressTable.insertRow(lastRow); //add the label cell cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode(' ')); //add the input cell cell = row.insertCell(1); inputBox = document.createElement('input'); inputBox.type = 'text'; inputBox.name = 'addresstwo[]'; inputBox.id = 'addresstwo[]'; inputBox.size = 40; inputBox.maxLength = 50; cell.appendChild(inputBox); //add the third row //find out which row this is lastRow++; iteration = lastRow + 1; row = addressTable.insertRow(lastRow); //add the label cell cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode(' ')); //add the input cell cell = row.insertCell(1); inputBox = document.createElement('input'); inputBox.type = 'text'; /*inputBox.name = 'addressthree[' + iteration + ']'; inputBox.id = 'addressthree[' + iteration + ']';*/ inputBox.name = 'addressthree[]'; inputBox.id = 'addressthree[]'; inputBox.size = 40; inputBox.maxLength = 50; cell.appendChild(inputBox); //add the city, state, zip row lastRow++; iteration = lastRow + 1; row = addressTable.insertRow(lastRow); //add the label cell cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode('City, State and Zip:')); //add the input cells cell = row.insertCell(1); //add city inputBox = document.createElement('input'); inputBox.type = 'text'; /*inputBox.name = 'city[' + iteration + ']'; inputBox.id = 'city[' + iteration + ']';*/ inputBox.name = 'city[]'; inputBox.id = 'city[]'; inputBox.size = 20; inputBox.maxLength = 50; cell.appendChild(inputBox); //add separator cell.appendChild(document.createTextNode(', ')); //add state var stateSelect = document.createElement('select'); //stateSelect.name = 'state[' + iteration + ']'; stateSelect.name = 'state[]'; stateSelect.options[0] = new Option('[State]', ''); stateSelect.options[1] = new Option('AK', 'AK'); stateSelect.options[2] = new Option('AL', 'AL'); stateSelect.options[3] = new Option('AR', 'AR'); stateSelect.options[4] = new Option('AZ', 'AZ'); stateSelect.options[5] = new Option('CA', 'CA'); stateSelect.options[6] = new Option('CO', 'CO'); stateSelect.options[7] = new Option('CT', 'CT'); stateSelect.options[8] = new Option('DC', 'DC'); stateSelect.options[9] = new Option('DE', 'DE'); stateSelect.options[10] = new Option('FL', 'FL'); stateSelect.options[11] = new Option('GA', 'GA'); stateSelect.options[12] = new Option('HI', 'HI'); stateSelect.options[13] = new Option('IA', 'IA'); stateSelect.options[14] = new Option('ID', 'ID'); stateSelect.options[15] = new Option('IL', 'IL'); stateSelect.options[16] = new Option('IN', 'IN'); stateSelect.options[17] = new Option('KS', 'KS'); stateSelect.options[18] = new Option('KY', 'KY'); stateSelect.options[19] = new Option('LA', 'LA'); stateSelect.options[20] = new Option('MA', 'MA'); stateSelect.options[21] = new Option('MD', 'MD'); stateSelect.options[22] = new Option('ME', 'ME'); stateSelect.options[23] = new Option('MI', 'MI'); stateSelect.options[24] = new Option('MN', 'MN'); stateSelect.options[25] = new Option('MO', 'MO'); stateSelect.options[26] = new Option('MS', 'MS'); stateSelect.options[27] = new Option('MT', 'MT'); stateSelect.options[28] = new Option('NC', 'NC'); stateSelect.options[29] = new Option('ND', 'ND'); stateSelect.options[30] = new Option('NE', 'NE'); stateSelect.options[31] = new Option('NH', 'NH'); stateSelect.options[32] = new Option('NJ', 'NJ'); stateSelect.options[33] = new Option('NM', 'NM'); stateSelect.options[34] = new Option('NV', 'NV'); stateSelect.options[35] = new Option('NY', 'NY'); stateSelect.options[36] = new Option('OH', 'OH'); stateSelect.options[37] = new Option('OK', 'OK'); stateSelect.options[38] = new Option('OR', 'OR'); stateSelect.options[39] = new Option('PA', 'PA'); stateSelect.options[40] = new Option('RI', 'RI'); stateSelect.options[41] = new Option('SC', 'SC'); stateSelect.options[42] = new Option('SD', 'SD'); stateSelect.options[43] = new Option('TN', 'TN'); stateSelect.options[44] = new Option('TX', 'TX'); stateSelect.options[45] = new Option('UT', 'UT'); stateSelect.options[46] = new Option('VA', 'VA'); stateSelect.options[47] = new Option('VT', 'VT'); stateSelect.options[48] = new Option('WA', 'WA'); stateSelect.options[49] = new Option('WI', 'WI'); stateSelect.options[50] = new Option('WV', 'WV'); stateSelect.options[51] = new Option('WY', 'WY'); cell.appendChild(stateSelect); //add separator cell.appendChild(document.createTextNode(' ')); //add zip inputBox = document.createElement('input'); inputBox.type = 'text'; /*inputBox.name = 'zip[' + iteration + ']'; inputBox.id = 'zip[' + iteration + ']';*/ inputBox.name = 'zip[]'; inputBox.id = 'zip[]'; inputBox.size = 10; inputBox.maxLength = 10; cell.appendChild(inputBox); //add spacer row //make the new row lastRow++; iteration = lastRow + 1; row = addressTable.insertRow(lastRow); //add the blankrow cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode(' ')); cell = row.insertCell(1); cell.appendChild(document.createTextNode(' ')); } function addPhone() { //adds a phone number field //make sure it's supported if (!document.getElementById || !document.createElement) return; //add the address type row //make the new row var phoneTable = document.getElementById('phones'); var lastRow = phoneTable.rows.length; var row = phoneTable.insertRow(lastRow); //add the label cell cell = row.insertCell(0); cell.className = 'rightalignlabel'; cell.appendChild(document.createTextNode('Phone Number:')); //add the input cell cell = row.insertCell(1); //add the phone type selector var phoneType = document.createElement('select'); phoneType.name = 'phonetype[]'; phoneType.options[0] = new Option('Work', 'work'); phoneType.options[1] = new Option('Home', 'home'); phoneType.options[2] = new Option('Mobile', 'cell'); phoneType.options[3] = new Option('Fax', 'fax'); phoneType.options[4] = new Option('Other', 'other'); cell.appendChild(phoneType); //add the separator cell.appendChild(document.createTextNode(' ')); //add the area code block var areaCode = document.createElement('input'); areaCode.type = 'text'; areaCode.name = 'phoneareacode[]'; areaCode.size = 3; areaCode.maxLength = 3; cell.appendChild(areaCode); //add the separator cell.appendChild(document.createTextNode(' - ')); //add the exchange code block var exchange = document.createElement('input'); exchange.type = 'text'; exchange.name = 'phoneexchange[]'; exchange.size = 3; exchange.maxLength = 3; cell.appendChild(exchange); //add the separator cell.appendChild(document.createTextNode(' - ')); //add the number block var phoneNumber = document.createElement('input'); phoneNumber.type = 'text'; phoneNumber.name = 'phonenumber[]'; phoneNumber.size = 4; phoneNumber.maxLength = 4; cell.appendChild(phoneNumber); //add the separator cell.appendChild(document.createTextNode(' x')); //add the extension block var extension = document.createElement('input'); extension.type = 'text'; extension.name = 'phoneextension[]'; extension.size = 4; extension.maxLength = 5; cell.appendChild(extension); } function handleOther(id) { if(document.getElementById(id).value == 'other') { //show other block document.getElementById(id + 'other').style.visibility = 'visible'; } else { //hide other block document.getElementById(id + 'other').style.visibility = 'hidden'; } } function updateDear() { try { var dearField = document.getElementById('dearfield'); var firstNameField = document.getElementById('firstnamefield'); var lastNameField = document.getElementById('lastnamefield'); if(!dearField || !firstNameField || !lastNameField) return; document.getElementById('dearfield').value = document.getElementById('firstnamefield').value + ' ' + document.getElementById('lastnamefield').value; } catch(e) {} }