//formCheck on submit make sure form maintains state function formCheck(form, businessChoice, marketChoice, companytypeChoice, sampleChoice) { displayCheck(form); checkCompType(companytypeChoice); //requiredAsterisks(form,sampleChoice); populateCompanyType(form,businessChoice,companytypeChoice); formSwitch(form,businessChoice); //populateMarkets(form,businessChoice,marketChoice); //subMarketCheck(form,marketChoice); } function limitText(form) { var limitNum = 250; var limitField = document.getElementById("helpField"); var limitCount = document.getElementById("countdown"); if (limitField.value.length > limitNum) { limitField.value = limitField.value.substring(0, limitNum); } else { limitCount.value = limitNum - limitField.value.length; } } function subMarketCheck(form,marketChoice) { var submktRow = document.getElementById("submarketRow"); if(marketChoice == "Filtration / Separation") { submktRow.style.display = ""; } else { form.submarket.selectedIndex = 0; submktRow.style.display = "none"; } } //updateBusiness onChange, effect all elements dependant on the SBU choosen function updateBusiness(form,selection){ var selValue = selection.options[selection.selectedIndex].getAttribute('show'); //var marketRow = document.getElementById("marketRow"); //marketRow.style.display = (selValue == "marketField") ? "" : "none"; //form.market.selectedIndex = 0; //form.submarket.selectedIndex = 0; //var busVal = selection.options[selection.selectedIndex].value; //if(busVal != 2) { // var submktRow = document.getElementById("submarketRow"); // submktRow.style.display = "none"; //} //updatePublications(selection); //populateMarkets(form,selection); formSwitch(form, selection); populateCompanyType(form,selection); resetCompanyOther(form); //resetPublicationOther(form); } function formSwitch(form,selection) { var busSelect = selection.selectedIndex; var businessID = form.business[busSelect].value; //let's switch the for based on either tech spec //or everything else //switch it up if(businessID == 2) { var techtitle = "

Custom Product Inquiry Form

"; document.getElementById("formTitle").innerHTML = techtitle; var helpRow = document.getElementById("help"); helpRow.style.display = "none"; var charcountRow = document.getElementById("charCount"); charcountRow.style.display = "none"; var techhelpRow = document.getElementById("techHelp"); techhelpRow.style.display = ""; var techSpecRow = document.getElementById("techSpecs"); techSpecRow.style.display = ""; var techUseRow = document.getElementById("techUse"); techUseRow.style.display = ""; form.help.value = "How can we help you? (250 Characters)"; form.countdown.value = 250; } else { var title = "

FiberMark Inquiry Form

"; document.getElementById("formTitle").innerHTML = title; var helpRow = document.getElementById("help"); helpRow.style.display = ""; var charcountRow = document.getElementById("charCount"); charcountRow.style.display = ""; var techhelpRow = document.getElementById("techHelp"); techhelpRow.style.display = "none"; var techSpecRow = document.getElementById("techSpecs"); techSpecRow.style.display = "none"; var techUseRow = document.getElementById("techUse"); techUseRow.style.display = "none"; form.techProp.value = "Performace Properties*"; form.techSpecs.value = "Product Specifications*"; form.techUse.value = "Intended Use*"; } } //if onChange a different SBU is chosen, hide the companyOther form field, //and reset it back to default text function resetCompanyOther(form) { var companyOtherRow = document.getElementById("companyOtherRow"); companyOtherRow.style.display = "none"; form.companyother.value = "Please specify"; } // if onChange a different SBU is chosen, hide the publicationOther form field // and reset to default text, also uncheck all the otherPub checkboxes // we need to do this because all the "otherPub" checkboxes have the same ID // and could have been selected previously then the SBU changed, // which would cause the checkbox to re-check itself even if it was unchecked function resetPublicationOther(form) { var publicationOtherRow = document.getElementById("publicationOtherRow"); publicationOtherRow.style.display = "none"; form.publicationOther.value = "Please list other publications"; var otherPubArray = eval(otherPubsArray); for (var i=0; i < otherPubArray.length; i++) { document.getElementById(eval(otherPubArray[i])).checked = false; } } //if onClick, requestSamples is yes, add astrisks to all additiional required fields //if samples is no, then remove all astrisks function requiredAsterisks(form,selection) { if(selection == "yes") { if(form.address1.value == "Address*" || form.address1.value == "Address" || form.address1.value == "") { form.address1.value = "Address*"; } if(form.city.value == "City*" || form.city.value == "City" || form.city.value == "") { form.city.value = "City*"; } //if(form.state.selectedIndex == 0) { //form.state.options[form.state.selectedIndex].text = "State/Province*"; //} if(form.zip.value == "Postal Code*" || form.zip.value == "Postal Code" || form.zip.value == "") { form.zip.value = "Postal Code*"; } } else { if(form.address1.value == "Address*" || form.address1.value == "Address" || form.address1.value == "") { form.address1.value = "Address"; } if(form.city.value == "City*" || form.city.value == "City" || form.city.value == "") { form.city.value = "City"; } //if(form.state.selectedIndex == 0) { //form.state.options[form.state.selectedIndex].text = "State/Province"; //} if(form.zip.value == "Postal Code*" || form.zip.value == "Postal Code" || form.zip.value == "") { form.zip.value = "Postal Code"; } } } //if onChange the companyType selection is equal to "Other" //display the other company type row function updateCompanyType(sel){ var selIndex = sel.selectedIndex; var selValue = sel.options[selIndex].text; var companyOtherRow = document.getElementById("companyOtherRow"); companyOtherRow.style.display = (selValue == "Other") ? "" : "none"; } //update the publication list that is displayed when a new SBU is chosen onChange function updatePublications(selection){ var selectedBusiness = selection.options[selection.selectedIndex].value; var publicationRowID = "publicationRow" + selectedBusiness; var publicationArray = eval(publicationsArray); for (var i=0; i < publicationArray.length; i++) { if(publicationRowID == eval(publicationArray[i])) { document.getElementById(eval(publicationArray[i])).style.display = ""; } else { document.getElementById(eval(publicationArray[i])).style.display = "none"; } } } //if the otherPublication checkbox is checked onChange //display the otherpublications form field //if onCHange the checkbox is not checked, then hide the //otherpublications form field, reset it to default text //and reset all otherPublication checkboxes to false function otherPublicationsRow(selection) { var otherPubArray = eval(otherPubsArray); if (selection.checked) { document.getElementById("publicationOtherRow").style.display = ""; } else { document.getElementById("publicationOtherRow").style.display = "none"; document.inquiries.publicationOther.value = "Please list other publications"; for (var i=0; i < otherPubArray.length; i++) { document.getElementById(eval(otherPubArray[i])).checked = false; } } } //on an unsuccessful form submission, make sure the state of all variable elements //was maintained, based all on the business choice function displayCheck(form){ businessField = form.business.options[form.business.selectedIndex].getAttribute('show'); //var marketRow = document.getElementById('marketRow'); //marketRow.style.display = (businessField == "marketField") ? "" : "none"; //checkPubRow(form); //checkPubOtherRow(form); } //on an unsuccessful form submission, determine the last state of the //company type field, and show/hide the companyotherrow accordingly function checkCompType(companyType) { var companyOtherRow = document.getElementById('companyOtherRow'); companyOtherRow.style.display = (companyType == "Other") ? "" : "none"; } //on an unsuccessful form submission, determine the last state of the //publication row, and show/hide the publication row according to the chosen SBU function checkPubRow(form) { businessField = form.business.options[form.business.selectedIndex].value; var publicationRowID = "publicationRow" + businessField; var publicationArray = eval(publicationsArray); for (var i=0; i < publicationArray.length; i++) { if(publicationRowID == eval(publicationArray[i])) { document.getElementById(eval(publicationArray[i])).style.display = ""; } else { document.getElementById(eval(publicationArray[i])).style.display = "none"; } } } //on an unsuccessful form submission, determine the last state of the //otherPublication checkboxes, and show/hide the other publication row if its checked function checkPubOtherRow(form) { var otherPubArray = eval(otherPubsArray); for (var i=0; i < otherPubArray.length; i++) { if(document.getElementById(eval(otherPubArray[i])).checked) { document.getElementById("publicationOtherRow").style.display = ""; } } } //Company type arrays //Array for Office var companytype1Array = new Array( "('Type of Company?','',true,true)", "('Manufacturer / Converter')", "('Paper Merchant')", "('Retail')", "('Other')" ); //Array for technical var companytype2Array = new Array( "('Type of Company?','',true,true)", "('Manufacturer/converter')", "('Agent/distributor')", "('Other')" ); //Array for decorative coverings var companytype3Array = new Array( "('Type of Company?','',true,true)", "('Publisher')", "('Component Printer')", "('Book Binder')", "('Designer')", "('Corporate Brand Holder')", "('Agent / Distributor')", "('Yearbook')", "('Date & Diary')", "('Photo Album Manufacturer')", "('Ring Binder Manufacturer')", "('Catalog')", "('Menu')", "('Other')" ); //Array for Paper Crafting var companytype5Array = new Array( "('Type of Company?','',true,true)", "('Retail')", "('Other')" ); //Array for Graphic Design var companytype6Array = new Array( "('Type of Company?','',true,true)", "('Publisher')", "('Bindery')", "('Printer')", "('Distributor')", "('Corporate Brand Owner')", "('Other')" ); //Array for Graphic Design var companytype18Array = new Array( "('Type of Company?','',true,true)", "('Publisher')", "('Bindery')", "('Printer')", "('Distributor')", "('Corporate Brand Owner')", "('Other')" ); //function chooses which market drop down to display //depending on which business was chosen function populateMarkets(form,businessChoice,chosenApp) { var selected = businessChoice.options[businessChoice.selectedIndex].value; //var selected = businessChoice; var marketArray = new Array(); if(marketArray.length != 0) { while (marketArray.length < form.market.options.length) { form.market.options[(form.market.options.length - 1)] = null; } for (var i=0; i < marketArray.length; i++) { eval("form.market.options[i]=" + "new Option" + marketArray[i]); if(chosenApp == eval(marketArray[i])) { form.market.options.selectedIndex = i; } } } } //function chooses which companyType drop down to display //depending on which SBU was chosen function populateCompanyType(form,businessChoice,chosenType) { var selected = businessChoice.options[businessChoice.selectedIndex].value; //var selected = businessChoice; if(selected != 0 || selected != "") { var companyTypeRow = document.getElementById('companyTypeRow'); companyTypeRow.style.display = ""; } else { var companyTypeRow = document.getElementById('companyTypeRow'); companyTypeRow.style.display = "none"; } var companytypeArray = new Array(); if (selected == "3") { var companytypeArray = eval("companytype3Array"); } if (selected == "6") { var companytypeArray = eval("companytype6Array"); } if (selected == "1") { var companytypeArray = eval("companytype1Array"); } if (selected == "5") { var companytypeArray = eval("companytype5Array"); } if (selected == "18") { var companytypeArray = eval("companytype18Array"); } if (selected == "2") { var companytypeArray = eval("companytype2Array"); } if(companytypeArray.length != 0) { while (companytypeArray.length < form.companyType.options.length) { form.companyType.options[(form.companyType.options.length - 1)] = null; } for (var i=0; i < companytypeArray.length; i++) { eval("form.companyType.options[i]=" + "new Option" + companytypeArray[i]); if(chosenType == eval(companytypeArray[i])) { form.companyType.options.selectedIndex = i; } } } }