guyfromfl Posted August 26, 2009 Share Posted August 26, 2009 ok i've been mulling this over for 2 days now and cant figure out what i need to do to make this work. $functionName = the name that is printed in the dropdown box and description of what it does $functionValue = what you program into CV33-61 to make the engine to what the drop down list says $defaultValue = the factory default list. What it does is itterate through the cvs 33-61 and create a table row with the function number, dropdown list, the cv (memory location in the engine, and the value you would set to make it do what you select in the drop down list. There is a controller with buttons so if you hit Function 2 on the controller it does what ever value is set in CV35. $i goes through all the CVs 33-61 $func is the offset so CV33 = array location 0 (corresponds to the function number) $n is the itteration for each dropdown to figure out if this is default value.. The problem is function 14 where it says 30 in the default list, I need the drop list to say Industrial Sounds and so on... Ok here is the code: 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]'"; // if ($n == $defaultValues[$func]) { if ($defaultValues[$func] == $n) { $row .= " selected='selected'"; } $row .= ">$fN</option>"; $n++; } $row .= "</select></td><td>$i</td><td><input type='text' size='8' name='funcValue$i' value='" . $defaultValues['$func'] . "' /></td></tr>"; echo $row; } } And this is the script in action http://bli.servehttp.com/bli/knowledgebase/calculator.php#functions I hope thats clear enough to get the idea Thanks Quote Link to comment Share on other sites More sharing options...
ignace Posted August 26, 2009 Share Posted August 26, 2009 $defaultValues['$func'] should be: $defaultValues[$func] Quote Link to comment 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.