Hi Spammer, thanks. Your answer
- Name the inputs as one of the three previous options but using explicit keys for the arrays (eg, "foo[1]" or "foo[n][1]").
helped me figure out a solution to the first of the two questions. I also found the solution to the 2nd question using goggle. The solutions are below. I answered your questions as to what I am doing in the next paragraph.
Each row represents information about a person and the 3 columns are musical volume level settings on musical equipment pertaining to this person. Specifically the level setting on their instrument, the level setting on the input of a mixing board to reduce distortion and the level setting of the fader which provides further gain to the output amps. So foo could easily be renamed "SoundPot" since these level controls are typically called pots regardless of whether they spin or slide. The purpose is to gradually get these settings optimized so that these equipment settings can be set before the song starts to play (or at least they are very close to the proper settings). So there will typically be 3 to 5 rows and 3 columns per row. Getting the table filled out and initially presented to the user (me) and the default values set on the text boxes is not a problem (I have done lots of these). All my questions are on the input side after I have changed all the values (all rows and all 3 columns). So since one database row contains the 3 values on that row it would be ideal to have a single loop rather than 3 loops. The row's record would be read with a select query and if any of the three soundpot settings had changed relative to the record the record would be updated. Once that record was processed this way the loop would move to the next row and the next record would be read and again the three soundpot values on that row would be compared to the 3 values on that database record and if any had changed the new value would be moved in and that database record would be updated.
THE SOLUTION TO QUESTION #1:
I used the same query that put the table out on the client's browser but if this is true "if (isset($_POST['ProcessTextBoxes']))" I loop as shown in the code below to get the three values.
Code: Select all
echo("<td style='background-color:transparent;border:1px #c0c0c0 solid;text-align:left;vertical-align:top;height:18px;' > <input type='textbox' name='foo1of3[]' value='$SoundLevel1of3' onchange='funcEditValue($SoundLevel1of3,$RowCnt)'></td>\n");
echo("<td style='background-color:transparent;border:1px #c0c0c0 solid;text-align:left;vertical-align:top;height:18px;' > <input type='textbox' name='foo2of3[]' value='$SoundLevel2of3' onchange='funcEditValue($SoundLevel2of3,$RowCnt)'></td>\n");
echo("<td style='background-color:transparent;border:1px #c0c0c0 solid;text-align:left;vertical-align:top;height:18px;' > <input type='textbox' name='foo3of3[]' value='$SoundLevel3of3' onchange='funcEditValue($SoundLevel3of3,$RowCnt)'></td>\n");
Code: Select all
// ProcessTextBoxes ============================================================================================= ProcessTextBoxes
if (isset($_POST['ProcessTextBoxes'])) {
//In here execute the same mysql query that was used to display the table in the first place.
$RowCnt=0;
while($row = mysqli_fetch_array($result)) {
$fldKRP_Key = $row['fldKRP_Key'];
$fldKRP_SoundPot1of3 = $row['fldKRP_SoundPot1of3'];
$fldKRP_SoundPot2of3 = $row['fldKRP_SoundPot2of3'];
$fldKRP_SoundPot3of3 = $row['fldKRP_SoundPot3of3'];
$SoundPot1of3 = $_POST['foo1of3'][$RowCnt]; //These are the statements I have never done before
$SoundPot2of3 = $_POST['foo2of3'][$RowCnt]; //These are the statements I have never done before
$SoundPot3of3 = $_POST['foo3of3'][$RowCnt]; //These are the statements I have never done before
$RowCnt=$RowCnt + 1;
if ($SoundPot1of3 != $fldKRP_SoundPot1of3 or $SoundPot2of3 != $fldKRP_SoundPot2of3 or $SoundPot3of3 != $fldKRP_SoundPot3of3) {
funcUpdateTheRecord($fldKRP_Key,$SoundPot1of3,$SoundPot2of3,$SoundPot3of3 );
}
}
}
QUESTION #2:
I solved this one too. The question was how do I edit the values the user submits using javascript and if there are errors display them back to the user without the form being sent down to the server.
The solution. I searched google and found an example of the "this.value" to submit to the function as shown in the code below. I also had to put in Size='7' to get the text boxes smaller.
Code: Select all
echo("<td style='background-color:transparent;border:1px #c0c0c0 solid;text-align:left;vertical-align:top;width:5px;height:18px;' ><input type='textbox' name='foo1of3[]' value='$SoundLevel1of3' size='7' onchange='funcEditValue(this.value)'></td>\n");
echo("<td style='background-color:transparent;border:1px #c0c0c0 solid;text-align:left;vertical-align:top;width:5px;height:18px;' ><input type='textbox' name='foo2of3[]' value='$SoundLevel2of3' size='7' onchange='funcEditValue(this.value)'></td>\n");
echo("<td style='background-color:transparent;border:1px #c0c0c0 solid;text-align:left;vertical-align:top;width:5px;height:18px;' ><input type='textbox' name='foo3of3[]' value='$SoundLevel3of3' size='7' onchange='funcEditValue(this.value)'></td>\n");