Jump to content

Adding options in select


Recommended Posts

I've done a bit of testing and when I output the length of reserveList at the end of restoreOptions() I only get a length of 5. So it seems that it's not filling up completely for some reason. I have 20 options in process. No matter what option I choose in select 1 it always loads the same 5 options on the first onChange. Second onChange I get less options but different.I removed the removeOptions() function for testing so it should just be filling up completely now...

Link to post
Share on other sites
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>OECD</title>		<style type="text/css">	@import url("/pdbis/oecd/oecd/oecd.css");	</style>	<script language="JavaScript1.2" type="text/javascript">		function validateSearchText() {			if (document.searchText.keywords.value == "") {				alert("Please enter a search string");				return false;			}			document.searchText.submit();			document.searchText.keywords.value = "";			return true;		}	</script></head><body><div id="container"><div id="header">  <div id="oecdlogo"></div>  <div id="slogan">    <p id="top">Organisation for Economic Co-operation and Development</p>    <p id="bottom">Building Partnerships for Progress</p>  </div>  <div id="searchbox">    <form action="/pdbis/oecd/oecd/search_e.cfm" method="post" name="searchText">      Search RET Documents<br>      <input name="keywords" size="30" type="text">       <input value="Search" name="Operation1" onclick="return validateSearchText();" type="submit"><br>      <input name="cri" value="or" checked="checked" type="radio">      Any Match      <input name="cri" value="and" type="radio">      Exact Match    </form>  </div>  <div id="banner">    <h1>Resource Centre for PRTR Release Estimation Techniques (RETs)</h1>  </div>  <div id="userlogged">  	<strong>Logged in as V, Chris</strong> (<a href="/pdbis/oecd/oecd/admin/logout.cfm">logout</a>)  </div></div><div id="leftnav">    	<ul>		<li class="listheader"><a href="/pdbis/oecd/oecd/admin/enter_doc.cfm">Ressource Center Admin</a></li>		<li><a href="/pdbis/oecd/oecd/admin/enter_doc.cfm">Enter a new Document</a></li>		<li><a href="/pdbis/oecd/oecd/admin/view_docs.cfm">Edit Documents</a></li>		<li><a href="/pdbis/oecd/oecd/admin/del_docs.cfm">Delete Documents</a></li>					<li><a href="/pdbis/oecd/oecd/admin/restore_docs.cfm">Restore Documents</a></li>				<li><a href="/pdbis/oecd/oecd/admin/user_guide.pdf">User's Guide</a></li>		<li><a href="update_user.cfm">Update Your Profile</a></li>	</ul>			<ul>			<li class="listheader">User Admin</li>			<li><a href="approval.cfm">Approve New Users</a></li>			<li><a href="register.cfm">Register New Users</a></li>			<li><a href="remove_user.cfm">Remove Users</a></li>		</ul>	</div> <script language="javascript">function showElements() {	if(document.getElementById('docType').value == 20){		document.getElementById('estMethodContainer').style.display = 'block';	} else {		document.getElementById('estMethodContainer').style.display = 'none';	}}function toggleVisible(itemName) {	<!-- Erase containers on new selection -->	document.getElementById('sourceTypeContainer').style.display = 'none';	document.getElementById('CASNumberContainer').style.display = 'none';	document.getElementById('ISICCodeContainer').style.display = 'none';	document.getElementById('processGroupContainer').style.display = 'none';	document.getElementById('processContainer').style.display = 'none';	document.getElementById('areaSourceContainer').style.display = 'none';	document.getElementById('docTypeContainer').style.display = 'none';	document.getElementById('estMethodContainer').style.display = 'none';		switch(itemName) {		<!-- Source Classification -->		case 'Point Source':			document.getElementById('sourceTypeContainer').style.display = 'block';			break;		case 'Non-Point Source':			document.getElementById('areaSourceContainer').style.display = 'block';			document.getElementById('docTypeContainer').style.display = 'block';			break;							<!-- Source Types -->		case 'Industry':			document.getElementById('sourceTypeContainer').style.display = 'block';			document.getElementById('ISICCodeContainer').style.display = 'block';			document.getElementById('docTypeContainer').style.display = 'block';			break;		case 'Industrial Process/Activity':			document.getElementById('sourceTypeContainer').style.display = 'block';			document.getElementById('processGroupContainer').style.display = 'block';			document.getElementById('processContainer').style.display = 'block';			document.getElementById('docTypeContainer').style.display = 'block';			document.getElementById('estMethodContainer').style.display = 'block';			break;		case 'Chemicals':			document.getElementById('sourceTypeContainer').style.display = 'block';			document.getElementById('CASNumberContainer').style.display = 'block';			document.getElementById('docTypeContainer').style.display = 'block';			break;	}}var i;var reserveListLoaded = false;var reserveList, processLength, processGroup, process;function removeOptions(){  for(i=processLength-1;i>=0;i--)   {		if(processGroup.options[processGroup.selectedIndex].value != process.options[i].value && process.options[i].value != 'default' && processGroup.options[processGroup.selectedIndex].value != 'default')		{			process.remove(i);		}	}}function restoreOptions(){  if(!reserveListLoaded)  {    reserveListLoaded = true;    for(i=0;i<processLength;i++)    {      reserveList.options[i] = process.options[i];    }  }    for(i=0;i<reserveList.options.length;i++)  {	process.options[i] = null;	process.options[i] = reserveList.options[i];		  }}function processGroupOnChange(){  restoreOptions();  removeOptions();}</script><div id="content">	<h1>PRTR Resource Centre Data Entry form</h1>					<p><strong><span class="star">*</span> Mandatory fields</strong></p>		<form name="submitDocForm" method="post" action="/pdbis/oecd/oecd/admin/submit_doc.cfm" class="thinform">		<p><label>Country <span class="star">*</span></label>		Canada 		</p>				<p><label>Language <span class="star">*</span></label>		<input name="language" value="english" type="radio"> English		<input name="language" value="french" type="radio"> French</p>				<hr>				<p><label>Source Classification <span class="star">*</span></label>		<input name="sourceClass" value="Point Source" onclick="toggleVisible(this.value);" type="radio"> Point Source<br>		<input name="sourceClass" value="Non-Point Source" onclick="toggleVisible(this.value);" type="radio"> Non-Point Source<br>		<input name="sourceClass" value="Overarching Document" onclick="toggleVisible(this.value);" type="radio"> Overarching Document<br>		<input name="sourceClass" value="Emission Scenario Document" onclick="toggleVisible(this.value);" type="radio"> Emission Scenario Document</p>				<div id="sourceTypeContainer">			<p><label>Source Type <span class="star">*</span></label>			<input name="sourceType" value="Industry" onclick="toggleVisible(this.value);" type="radio"> Industry<br>			<input name="sourceType" value="Industrial Process/Activity" onclick="toggleVisible(this.value);" type="radio"> Industrial Process/Activity<br>			<input name="sourceType" value="Chemicals" onclick="toggleVisible(this.value);" type="radio"> Chemicals</p>								</div>				<div id="CASNumberContainer">			<p><label>CAS Number <span class="small">(e.g. 11-11-1)</span> <span class="star">*</span></label>			<input name="CASNumber" type="text"> 			<a href="/pdbis/oecd/oecd/admin/LookupCAS.cfm" target="_blank"><img src="/pdbis/oecd/oecd/images/interrogation.jpg" align="top"></a></p>		</div>				<div id="ISICCodeContainer">			<p><label>ISIC Code <span class="small">(4 digits)</span> <span class="star">*</span></label>			<input name="ISICCode" maxlength="4" size="4" type="text"> 			<a href="/pdbis/oecd/oecd/admin/LookupISIC.cfm" target="_blank"><img src="/pdbis/oecd/oecd/images/interrogation.jpg" align="top"></a></p>		</div>				<div id="processGroupContainer">			<p><label>Process Group <span class="star">*</span></label>			<select name="processGroup" id="processGroup" onchange="processGroupOnChange();">				<option value="default">Make a Selection</option>									<option value="20">Coincidental Manufacture</option>									<option value="30">Combustion</option>									<option value="50">Electroplating</option>									<option value="60">Solid Waste Disposal</option>									<option value="40">Spray Application or Organic Coatings</option>									<option value="10">Wastewater Treatment</option>							</select></p>		</div>				<div id="processContainer">			<p><label>Process <span class="star">*</span> <span class="small"><a href="/pdbis/oecd/oecd/admin/addproc.cfm" target="_blank" id="addProcessLink">Add Process</a></span></label>			<select name="process" id="process">				<option value="default">Make a Selection</option>									<option value="30">Anthracite Coal Combustion  </option>									<option value="30">Bagasse Combustion in Sugar Mills </option>									<option value="30">Bituminous and Subbituminous Coal Combustion </option>									<option value="30">Fuel Oil Combustion</option>									<option value="30">Gasoline & Diesel Engines</option>									<option value="30">Heavy Duty Natural Gas</option>									<option value="30">Large Stationary Diesel</option>									<option value="30">Lignite Combustion </option>									<option value="30">Liquified Petroleum Gas Combustion</option>									<option value="30">Natural Gas Combustion</option>									<option value="20">Petroleum Refining</option>									<option value="30">Residential Fireplaces </option>									<option value="30">Residential Wood Stoves </option>									<option value="30">Stationary Gas Turbines</option>									<option value="30">Waste Oil Combustion </option>									<option value="20">Welding</option>									<option value="20">Wet Cooling Tower </option>									<option value="20">Wood preservation</option>									<option value="30">Wood Residue Combustion in Boilers</option>							</select></p>		</div>		20 - Coincidental Manufacture<br>		30 - Combustion<br>		50 - Electroplating<br>		60 - Solid Waste Disposal<br>		40 - Spray Application or Organic Coatings<br>		10 - Wastewater Treatment<br>				------------------------<br>		1050 - 30 - Anthracite Coal Combustion  <br>		1110 - 30 - Bagasse Combustion in Sugar Mills <br>		1040 - 30 - Bituminous and Subbituminous Coal Combustion <br>		1060 - 30 - Fuel Oil Combustion<br>		1020 - 30 - Gasoline & Diesel Engines<br>		1010 - 30 - Heavy Duty Natural Gas<br>		1030 - 30 - Large Stationary Diesel<br>		1100 - 30 - Lignite Combustion <br>		1080 - 30 - Liquified Petroleum Gas Combustion<br>		1070 - 30 - Natural Gas Combustion<br>		1170 - 20 - Petroleum Refining<br>		1120 - 30 - Residential Fireplaces <br>		1130 - 30 - Residential Wood Stoves <br>		1000 - 30 - Stationary Gas Turbines<br>		1140 - 30 - Waste Oil Combustion <br>		1150 - 20 - Welding<br>		1180 - 20 - Wet Cooling Tower <br>		1160 - 20 - Wood preservation<br>		1090 - 30 - Wood Residue Combustion in Boilers<br>				<div id="areaSourceContainer">			<p><label>Area Source <span class="star">*</span></label>			<select name="areaSource">				<option value="default">Make a Selection</option>									<option value="410"> Asphalt Paving Operations</option>									<option value="2150">Abrasive Blasting</option>									<option value="1880">Abrasives Manufacturing</option>									<option value="710">Acetone & Phenol</option>									<option value="540">Adipic Acid</option>									<option value="2130">Aggregate Handling and Storage Piles</option>									<option value="1450">Agricultural Wind Erosion</option>									<option value="1270">Alfalfa Dehydrating</option>									<option value="1330">Almond Processing</option>									<option value="1860">Alumina Manufacturing</option>									<option value="880">Ammonium Nitrate</option>									<option value="920">Ammonium Phosphate</option>									<option value="890">Ammonium Sulfate</option>									<option value="20">Anthracite Coal Combustion</option>									<option value="1580">Asphalt Roofing</option>									<option value="320">Automobile & Light Duty Truck Surface Coating</option>									<option value="170">Automobile Body Incineration</option>									<option value="80">Bagasse Combustion in Sugar Mills</option>									<option value="730">Benzene, Toluene & Xylenes</option>									<option value="10">Bituminous and Subbituminous Coal Combustion</option>									<option value="1290">Bread Baking</option>									<option value="1590">Bricks and Related Clay Products</option>									<option value="740">Butadiene</option>									<option value="1600">Calcium Carbide Manufacturing</option>									<option value="260">Can Coating</option>									<option value="1090">Cane Sugar Harvesting</option>									<option value="1310">Cane Sugar Processing</option>									<option value="1210">Canned Fruits and Vegetables</option>									<option value="530">Carbon Black</option>									<option value="1100">Cattle Feedlots</option>									<option value="1630">Ceramic Clay Manufacturing</option>									<option value="1250">Cereal Breakfast Food</option>									<option value="1550">Charcoal</option>									<option value="1470">Chemical Wood Pulping</option>									<option value="980">Chlor-Alkali</option>									<option value="1640">Clay and Fly Ash Sintering</option>									<option value="1820">Clay Processing</option>									<option value="1660">Coal Cleaning</option>									<option value="1670">Coal Conversion</option>									<option value="1400">Coffee Roasting</option>									<option value="1900">Coke Production</option>									<option value="470">Commercial/Consumer Solvent Use</option>									<option value="1680">Concrete Batching</option>									<option value="1300">Corn Wet Milling</option>									<option value="1200">Cotton Ginning</option>									<option value="1060">Cotton Harvesting</option>									<option value="1760">Crushed Stone Processing</option>									<option value="750">Cumene</option>									<option value="1130">Dairy Farms</option>									<option value="1220">Dehydrated Fruits and Vegetables</option>									<option value="1790">Diatomite Processing</option>									<option value="1380">Distilled Spirits</option>									<option value="2070">Electric Arc Welding</option>									<option value="2080">Electroplating</option>									<option value="2190">Emission from Soils -- Greenhouse Gases</option>									<option value="1570">Engineered Wood Products</option>									<option value="2220">Enteric Fermentation -- Greenhouse Gases</option>									<option value="760">Ethanol</option>									<option value="770">Ethyl Benzene</option>									<option value="780">Ethylene</option>									<option value="790">Ethylene Dichloride & Vinyl Chloride</option>									<option value="800">Ethylene Glycol</option>									<option value="810">Ethylene Oxide</option>									<option value="550">Explosives</option>									<option value="2160">Explosives Detonation</option>									<option value="1840">Feldspar Processing</option>									<option value="1920">Ferroalloy Production</option>									<option value="1030">Fertilizer Application</option>									<option value="1390">Fish Processing</option>									<option value="290">Flat Wood Interior Panel Coating</option>									<option value="820">Formaldehyde</option>									<option value="1700">Frit Manufacturing</option>									<option value="30">Fuel Oil Combustion</option>									<option value="200">Gasoline and Diesel Industrial Engines</option>									<option value="450">General Graphical Printing</option>									<option value="250">General Industrial Surface Coating</option>									<option value="1690">Glass Fiber Manufacturing</option>									<option value="1710">Glass Manufacturing</option>									<option value="830">Glycerine</option>									<option value="1240">Grain Elevators & Processes</option>									<option value="1070">Grain Harvesting</option>									<option value="1980">Gray Iron Foundries</option>									<option value="1720">Gypsum Manufacturing</option>									<option value="1540">Hardboard and Fiberboard</option>									<option value="2120">Heavy Construction Operations</option>									<option value="930">Hydrochloric Acid</option>									<option value="940">Hydrofluoric Acid</option>									<option value="1010">Hydrogen Cyanide</option>									<option value="2180">Industrial Flares</option>									<option value="2140">Industrial Wind Erosion</option>									<option value="240">Introduction to Industrial Surface Coating</option>									<option value="220">Introduction to Surface Coating</option>									<option value="1930">Iron and Steel Production</option>									<option value="840">Isopropyl Alcohol</option>									<option value="350">Large Appliance Surface Coating</option>									<option value="210">Large Stationary Diesel and All Stationary Dual-fu</option>									<option value="670">Lead Alkyl</option>									<option value="2040">Lead Oxide and Pigment Production</option>									<option value="2060">Leadbearing Ore Crushing and Grinding</option>									<option value="1440">Leather Tanning</option>									<option value="2210">Lightning Emissions -- Greenhouse Gases</option>									<option value="1770">Lightweight Aggregate</option>									<option value="70">Lignite Combustion</option>									<option value="1730">Lime Manufacturing</option>									<option value="50">Liquified Petroleum Gas Combustion</option>									<option value="1460">Lumber</option>									<option value="270">Magnet Wire Coating</option>									<option value="370">Magnetic Tape Manufacturing</option>									<option value="690">Maleic Anhydride</option>									<option value="1360">Malt Beverages</option>									<option value="490">Manufacture of Rubber Products</option>									<option value="1170">Manure Processing</option>									<option value="1140">Meat Packing Plants</option>									<option value="1160">Meat Rendering Plants</option>									<option value="1150">Meat Smokehouses</option>									<option value="140">Medical Waste Incineration</option>									<option value="1530">Medium Density Fiberboard</option>									<option value="340">Metal Coil Surface Coating</option>									<option value="360">Metal Furniture Surface Coating</option>									<option value="1810">Metallic Minerals Processing</option>									<option value="700">Methanol</option>									<option value="1740">Mineral Wool Manufacturing</option>									<option value="2050">Miscellaneous Lead Products</option>									<option value="150">Municipal Solid Waste Landfills</option>									<option value="1190">Natural and Processed Cheese</option>									<option value="40">Natural Gas Combustion</option>									<option value="520">Natural Gas Processing</option>									<option value="190">Natural Gas-fired Reciprocating Engines</option>									<option value="950">Nitric Acid</option>									<option value="230">Nonindustrial Surface Coating</option>									<option value="900">Normal Superphosphates</option>									<option value="160">Open Burning</option>									<option value="1050">Orchard Heaters</option>									<option value="850">Organic Liquid Storage Tanks</option>									<option value="280">Other Metal Coating</option>									<option value="560">Paint & Varnish</option>									<option value="300">Paper Coating</option>									<option value="1490">Papermaking</option>									<option value="1520">Particleboard</option>									<option value="1280">Pasta Manufacturing</option>									<option value="2100">Paved Roads</option>									<option value="1340">Peanut Processing</option>									<option value="1870">Perlite Manufacturing</option>									<option value="1040">Pesticide Application</option>									<option value="1260">Pet Food</option>									<option value="500">Petroleum Refining</option>									<option value="680">Pharmaceuticals Production</option>									<option value="1780">Phosphate Rock Processing</option>									<option value="960">Phosphoric Acid</option>									<option value="570">Phthalic Anhydride</option>									<option value="1230">Pickles, Sauces and Salad Dressings</option>									<option value="1500">Plywood Manufacturing</option>									<option value="590">Poly(ethylene terephthalate)</option>									<option value="400">Polyester Resin Plastic Products Fabrication </option>									<option value="310">Polymeric Coating of Supporting Substrates</option>									<option value="610">Polypropylene</option>									<option value="600">Polystyrene</option>									<option value="580">Polyvinyl Chloride</option>									<option value="1620">Portland Cement Manufacturing</option>									<option value="1120">Poultry Houses</option>									<option value="1180">Poultry Slaughtering</option>									<option value="330">Pressure Sensitive Tape and Labels</option>									<option value="1890">Primary Aluminum Production</option>									<option value="1910">Primary Copper Smelting</option>									<option value="1940">Primary Lead Smelting</option>									<option value="620">Printing Ink</option>									<option value="720">Propylene</option>									<option value="460">Publication Gravure Printing</option>									<option value="1480">Pulp Bleaching</option>									<option value="1610">Refractory Manufacturing</option>									<option value="120">Refuse Combustion</option>									<option value="90">Residential Fireplaces</option>									<option value="100">Residential Wood Stoves</option>									<option value="1080">Rice Harvesting</option>									<option value="1750">Sand & Gravel Processing</option>									<option value="1960">Secondary Aluminum Operations</option>									<option value="1970">Secondary Copper Smelting and Alloying</option>									<option value="1990">Secondary Lead Processing</option>									<option value="2000">Secondary Magnesium Smelting</option>									<option value="2020">Secondary Zinc Processing</option>									<option value="130">Sewage Sludge Incineration</option>									<option value="1410">Snack Chip Deep Fat Frying</option>									<option value="630">Soap and Detergents</option>									<option value="990">Sodium Carbonate</option>									<option value="420">Solvent Degreasing</option>									<option value="180">Stationary Gas Turbines</option>									<option value="2010">Steel Foundries</option>									<option value="2030">Storage Battery Production</option>									<option value="1320">Sugar Beet Processing</option>									<option value="1000">Sulfur Recovery</option>									<option value="970">Sulfuric Acid</option>									<option value="380">Surface Coating of Plastic Parts for Business Mach</option>									<option value="1110">Swine Feedlots</option>									<option value="860">Synthetic Ammonia</option>									<option value="640">Synthetic Fibers</option>									<option value="650">Synthetic Rubber</option>									<option value="1800">Taconite Ore Processing</option>									<option value="1830">Talc Processing</option>									<option value="440">Tank and Drum Cleaning</option>									<option value="660">Terephthalic Acid</option>									<option value="2200">Termites -- Greenhouse Gases</option>									<option value="480">Textile Fabric Printing</option>									<option value="1020">Tilling Operations</option>									<option value="1430">Tobacco Products</option>									<option value="510">Transportation and Marketing of Petroleum Liquids</option>									<option value="910">Triple Superphosphates</option>									<option value="2110">Unpaved Roads</option>									<option value="870">Urea</option>									<option value="1350">Vegetable Oil Processing</option>									<option value="1850">Vermiculite Processing</option>									<option value="1510">Waferboard Oriented Strandboard</option>									<option value="110">Waste Oil Combustion</option>									<option value="430">Waste Solvent Reclamation</option>									<option value="390">Waste Water Collection, Treatment and Storage</option>									<option value="1650">Western Surface Coal Mining</option>									<option value="2170">Wet Cooling Towers</option>									<option value="2090">Wildfires and Prescribed Burning</option>									<option value="1370">Wines and Brandy</option>									<option value="1560">Wood Preserving</option>									<option value="60">Wood Residue Combustion in Boilers</option>									<option value="1420">Yeast Production</option>									<option value="1950">Zinc Smelting</option>							</select></p>		</div>				<div id="docTypeContainer">			<p><label>Document Type <span class="star">*</span></label>			<select name="docType" id="docType" onchange="showElements();">				<option value="default" selected="selected">Make a Selection</option>							</select></p>		</div>				<div id="estMethodContainer">			<p><label>Estimation Method <span class="star">*</span></label>			<select name="estimationMethod">				<option value="default" selected="selected">Make a Selection</option>									<option value="10">Emission Factor Documents</option>									<option value="20">Emission Factor Databases</option>									<option value="30">Mass Balance</option>									<option value="40">Engineering Calculations</option>									<option value="50">Monitoring Information</option>							</select></p>		</div>				<hr>				<p><label>Document Source Organization <span class="star">*</span></label>		<input name="docOrg" value="ec" type="text"><br>		<label>Document Link <span class="star">*</span></label>		<input name="docLink" size="80" type="text"><br>		<label>Document Title <span class="star">*</span></label>		<input name="docTitle" size="80" type="text"></p>				<p><label>Document English Description <span class="star">*</span></label>		<textarea name="descE" cols="60" rows="8"></textarea></p>				<p><label>Document French Description</label>		<textarea name="descF" cols="60" rows="8"></textarea></p>				<hr>							<p><label>Country/Organization PRTR Site <span class="star">*</span></label>			<input name="prtrCO" type="text"><br>			<label>PRTR Representative <span class="star">*</span></label>			<input name="prtrRep" value="V, Chris" type="text"><br>			<label>PRTR Representative e-mail <span class="star">*</span></label>			<input name="prtrRepEmail" value="dd@cc.com" type="text"></p>				<hr>				<p><input name="save" value="Save Document" type="submit">		<input name="cancel" value="Cancel" type="submit"></p>	</form></div><script language="javascript">reserveList = document.createElement('select');processLength = document.getElementById('process').options.length;processGroup = document.getElementById('processGroup');process = document.getElementById('process');</script>	<div id="footer">		<a href="/pdbis/oecd/oecd/main_e.cfm">Home</a> |		<a href="/pdbis/oecd/oecd/contact.cfm">Contact Us</a> | 		<a href="/pdbis/oecd/oecd/faq_e.cfm">Help/FAQ</a> | 		<a href="http://www.oecd.org/SiteMap/0,2681,en_2649_201185_1_1_1_1_1,00.html">Site Map</a> |		<a href="#top">Top</a><br>		© OECD. All rights reserved.		<a href="http://www.oecd.org/document/0,2340,en_2649_201185_1899066_1_1_1_1,00.html">Terms & Conditions</a> | 		<a href="http://www.oecd.org/document/0,2340,en_2649_201185_1899048_1_1_1_1,00.html">Privacy Policy</a><br>		Powered by <a href="http://www.vignette.com/">Vignette</a>	</div></div></body></html>

Link to post
Share on other sites

I marked the changes I made with js comments

var i;var reserveListLoaded = false;var reserveList = document.createElement('select');  //you did not declare this as a selectvar processLength, processGroup, process;function removeOptions(){for(i=processLength-1;i>=0;i--){if(processGroup.options[processGroup.selectedIndex].value != process.options[i].value && process.options[i].value != 'default' && processGroup.options[processGroup.selectedIndex].value != 'default'){process.remove(i);}}}function restoreOptions(){if(!reserveListLoaded){reserveListLoaded = true;for(i=0;i<processLength;i++){reserveList.options[i] = new Option(process.options[i].text,process.options[i].value);  //changed this}}for(i=0;i<reserveList.options.length;i++){process.options[i] = null;process.options[i] = new Option(reserveList.options[i].text,reserveList.options[i].value);  //changed this}}

It is now working.

Link to post
Share on other sites

So do I still keep this at the bottom of the page?<script language="javascript">reserveList = document.createElement('select');processLength = document.getElementById('process').options.length;processGroup = document.getElementById('processGroup');process = document.getElementById('process');</script>Oh yeah and it works perfectly with the above js at the bottom of the page.Thanks a lot :)

Link to post
Share on other sites
  • 2 weeks later...

Ok I got another similar problem. I want to do the same except I have 3 values to play with. 1st one is the identifier (will tell me when to show certain options), 2nd is value (option value) and 3rd is the description (option description).I know how to handle 2 values but how would I handle 3 values? I can't just create a dup select like you did earlier, I got 3 values... Anyway around this?EDIT: Maybe this could work with commas. If the value was <option value="unique identifier, option value">option description</option> and when getting the info with JS I could remove the comma and everything in front. What you think of that and how can it be done?I am so close!

for(i=0;i<invisibleDocType.options.length;i++) {		docType.options[i] = null;		if(invisibleDocType.options[i].text.search(/optionFilter/) != -1){ 			docType.options[i] = new Option(invisibleDocType.options[i].text, invisibleDocType.options[i].value);		}	}

Somehow it doesn't find the match in the list but there is many matches. The output is no options in the list when there should be 3-4.

Link to post
Share on other sites

Seems like when I do if(invisibleDocType.options.text.search('ISIC4') != -1){ it works but when I replace it with the variable it doesn't. Ok got it working now it display the right options in my select.I got this code:

for(i=0;i<invisibleDocType.options.length;i++) {		docType.options[i] = null;		if(invisibleDocType.options[i].text != 'Make a Selection') {			splitOptionText = invisibleDocType.options[i].text.split(" --- ");			if(splitOptionText[0].search(optionFilter) != -1) { 				docType.options[i] = new Option(splitOptionText[1], invisibleDocType.options[i].value);			} 		} else {			docType.options[i] = new Option(invisibleDocType.options[i].text, invisibleDocType.options[i].value);		}	}

I got all the options I want but I have a bunch of empty options (should be the options that don't meet the if statement). How can I remove those blank options?Resolved!!! :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...