guyfromfl Posted August 24, 2009 Share Posted August 24, 2009 First, I am trying to figure out the best way to organize this. http://bli.servehttp.com/bli/knowledgebase/calculator.php#functions I have a list of dropdown boxes, and 3 arrays that control what values will be in the dropdown. Array 1 is the list of values for each dropdown box. Array 2 is the list of values you would program into the engine (a decimal value) (this has a 1:1 relation ship with Array 1) Array 3 is the list of default values programmed into the engine from the factory, so the correct selection of the dropdown will be displayed when the page is loaded. So basically When the page loads, it calls a php function that iterates through all 28 functions, and creates a new table row and dropdown each time. Now what I need the script to do is realize which cv it is creating and select it in the dropdown box... I hope that makes sense. Here is the code so far: function createDropdown() { $functionName = Array("Nothing", "Front/Rear Lights", "Bell Sound", "Horn Sound", "Couple/Uncouple Sound", "Compressor/Grid Blower Sound", "Diesel Ramp Up", "Disel Ramp Down/Start Diesel Sound", "L1 Function", "Mute/Volume Control", "Startup/Shutdown Sounds", "Cooling Fan Sound", "Air Fill/Air Release Sound", "Brake Set/Release/Squeal Sound", "Fuel Fill Sound", "Spit Valve Sound", "Wheel Flange Sound", "Coupler Slack Sound", "Brake Squeal Sound", "Horn2 Toggle", "Horn Grade Crossing Sound", "Play Macro", "Record Macro", "Passenger Sounds", "Freight Sounds", "Maintenance Sounds", "Radio Chatter", "City Sounds", "Farm Sounds", "Industrial Sounds", "Lumber Yard Sounds"); $functionValue = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ,12 ,13, 14, 15, 16, 17, 18, 19, 30, 40, 41, 50, 51, 52, 53, 54, 55, 56, 57); $defaultValues = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 30, 50, 51, 52, 53, 54, 55, 56, 57, 19, 0, 0, 0, 40, 41, 18); for ($i=33; $i<=61; $i++) { $func = $i-33; $row = "<tr class='isOdd'><td>$func</td><td><select name='func".$func."' />"; $n=0; foreach ($functionName as $fN) { $row .= "<option value='$functionValue[$n]'>$fN</option>"; $n++; } $row .= "</select></td><td>$i</td><td><input type='text' size='8' name='funcValue$i' /></td></tr>"; echo $row; } } Quote Link to comment https://forums.phpfreaks.com/topic/171703-solved-controlling-a-dropdown-with-3-arrays/ Share on other sites More sharing options...
guyfromfl Posted August 24, 2009 Author Share Posted August 24, 2009 Got it. It was staring me in the face. I just needed to compare the $i iteration with the $n foreach... Quote Link to comment https://forums.phpfreaks.com/topic/171703-solved-controlling-a-dropdown-with-3-arrays/#findComment-905411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.