Last edited by rhodarose; 12-15-2010 at 03:22 AM.
That's just a layout problem. You must have changed your PHP such that the inputs with theid='varqty#', which is written in the PHP file as:
now line up under the column in the table labeled MC #. In the zip file from your post #56 in this thread (which shows the HTML output of an earlier version of the PHP code), they line up under the proper column (VARIANCE Qty). Probably also in the txt file from your post #54 in this thread (which shows an earlier version of the PHP code), but I cannot be sure of that.Code:id='varqty" . $ctr . "'
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
An easy fix would be to just switch the two th elements in the PHP file here:
But then MC # heading or other column headings s might be in the wrong place. It's your layout, eventually you're going to have to understand it. Look at the source code in the browser like I said before using the browser's 'view source'. That may help you to understand how it's lining up.Code:<th class='myclass'>MC #</th><th class='myclass'>VARIANCE Qty</th>
Tables can be tricky to work with though. The only difference that jumps out at me from the old PHP code and the new that looks like it could be affecting this is here:
In the old file it was:Code:for($ctr = 0; $ctr < $trows; $ctr++) { $row = mysql_fetch_array($result); $tctr = $ctr + 1; echo "\n\t<tr>"; echo "\n\t\t<td width='800'>"; if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"]; $last_operation_name = $row["operation_name"]; echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='timein[]' id='timein" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='timeout[]' id='timeout" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' /></td>"; echo "\n\t\t<td>" . $row["input_unit"]; echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' ></td>"; echo "\n\t\t<td>" . $row["output_unit"]; echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>"; echo "\n\t\t<td><input size='6' type='text' name='idno[]' id='idno" . $ctr . "' /></td>";echo "\n\t\t<td><input size='6' type='text' name='varqty[]' id='varqty" . $ctr . "' /></td>";echo "\n\t\t<td><input size='6' type='text' name='varsublot[]' id='varsublot" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='dateshift[]' id='dateshift" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='shift[]' id='shift" . $ctr . "' /></td>"; echo "\n\t</tr>"; }
So you could either put that back, or if you don't need the MC #, leave it out and get rid of it here:Code:for($ctr = 0; $ctr < $trows; $ctr++) { $row = mysql_fetch_array($result); $tctr = $ctr + 1; echo "\n\t<tr>"; echo "\n\t\t<td width='800'>"; if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"]; $last_operation_name = $row["operation_name"]; echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='timein[]' id='timein" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='timeout[]' id='timeout" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' /></td>"; echo "\n\t\t<td>" . $row["input_unit"]; echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' ></td>"; echo "\n\t\t<td>" . $row["output_unit"]; echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>"; echo "\n\t\t<td><input size='6' type='text' name='idno[]' id='idno" . $ctr . "' /></td>";echo "\n\t\t<td><input size='6' type='text' name='mcno[]' id='mcno" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='varqty[]' id='varqty" . $ctr . "' /></td>";echo "\n\t\t<td><input size='6' type='text' name='varsublot[]' id='varsublot" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='dateshift[]' id='dateshift" . $ctr . "' /></td>"; echo "\n\t\t<td><input size='6' type='text' name='shift[]' id='shift" . $ctr . "' /></td>"; echo "\n\t</tr>"; }
However, if there were errors before that you didn't see, they may still exist. You see, the headings need to line up each with their respective columns of inputs. If they don't, then submitting the form may have different reults than intended. You won't be able to tell that until you do a few test submissions and see what data gets passed along or stored.Code:<th class='myclass'>MC #</th><th class='myclass'>VARIANCE Qty</th>
Last edited by jscheuer1; 12-15-2010 at 04:14 AM. Reason: add info
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
I fix it but adding
Thank you so muchPHP Code:echo "\n\t\t<td><input size='6' type='text' name='mcno[]' id='mcno" . $ctr . "' /></td>";
can you give the explanation of the code that you given
Thank you
Can you visit my other post about the sum of operation2 input qty and the result will be appear in input qty in operation2_total, because it is in the same code where i post here.
Thank you
Well, it's your own code. It was in the file that was 'working' before, but not in the one that wasn't. It puts another column in the table. Everything in that block of echo commands:
gets output (echoed) for each $trows. It (combined with the other code) creates a section of a table.PHP Code:for($ctr = 0; $ctr < $trows; $ctr++)
{
$row = mysql_fetch_array($result);
$tctr = $ctr + 1;
echo "\n\t<tr>";
echo "\n\t\t<td width='800'>";
if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];
$last_operation_name = $row["operation_name"];
echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='timein[]' id='timein" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='timeout[]' id='timeout" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' /></td>";
echo "\n\t\t<td>" . $row["input_unit"];
echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' ></td>";
echo "\n\t\t<td>" . $row["output_unit"];
echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>";
echo "\n\t\t<td><input size='6' type='text' name='idno[]' id='idno" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='mcno[]' id='mcno" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='varqty[]' id='varqty" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='varsublot[]' id='varsublot" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='dateshift[]' id='dateshift" . $ctr . "' /></td>";
echo "\n\t\t<td><input size='6' type='text' name='shift[]' id='shift" . $ctr . "' /></td>";
echo "\n\t</tr>";
}
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
what I mean is can you explain the code that you given:
Thank youCode:<script type="text/javascript"> document.onkeypress = function(e){ e = e || event; e.returnValue = true; var t = e.target || e.srcElement, re = /^(inqty|outqty)(\d+)$/, f = arguments.callee, m, i; function next(){ if(!f.els && (m = t.form) === document.forms.clttype){ var ipts = m.getElementsByTagName('input'), els = []; i = ipts.length - 1; for (i; i > -1; --i){ if(ipts[i].type && ipts[i].type.toLowerCase() === 'text'){ els.push(ipts[i]); } } f.els = els; } if(f.els){ i = f.els.length - 1; for (i; i > -1; --i){ if(f.els[i] === t && (m = f.els[i - 1])){ m.focus(); } } } } if((m = re.exec(t.id)) && e.keyCode === 13){ e.returnValue = false; t.form.elements['varqty' + m[2]].value = t.form.elements['inqty' + m[2]].value - t.form.elements['outqty' + m[2]].value; } else if (t.type && e.keyCode === 13 && t.type.toLowerCase() !== 'submit') { e.returnValue = false; } if(!e.returnValue){ next(); if(e.preventDefault){e.preventDefault();} } return e.returnValue; } </script>
Please stop quoting everything I type!
Here's an annotated version of the function:
Code:<script type="text/javascript"> document.onkeypress = function(e){ // Listens for any keypress for the entire document and gets a reference for the event (e) // for IE e will be null, if so set it to the global event; set the returnValue to true for now // e.returnValue has special meaning in IE, and is a valid arbitrary flag in all others: e = e || event; e.returnValue = true; // set some variables local to this function - t will be the element that received the keypress event, // re will be a regular expression used later to determine if inqty# or outqty# were the // id of the element and to capture the # part if so, // f becomes a reference to this function, m & i are set as local variables for later use // f is shorthand for the function, m is shorthad for match, i for item: var t = e.target || e.srcElement, re = /^(inqty|outqty)(\d+)$/, f = arguments.callee, m, i; // defines a function next() for later use locally within the keypress function // when the key is ENTER and certain other conditions (described below) are satisfied: function next(){ // if we haven't got the array of input elements for this form yet and this form is // the form with the name clttype, set m (from the above) = to the form for now // and execute the following bracketed code block. // f.els is a property we created or will create of the keypress function, // t.form is the parent form if any of the element that received the keypress // document.forms.clttype is a reference to the particular form we are interested in: if(!f.els && (m = t.form) === document.forms.clttype){ // set some variables local to the next() function // ipts will be all input elements in the form clttype, els will be // an empty array. Also set i (from above) to the number of inputs for now: var ipts = m.getElementsByTagName('input'), els = []; i = ipts.length - 1; for (i; i > -1; --i){ // for each input in the form if(ipts[i].type && ipts[i].type.toLowerCase() === 'text'){ // if it's a text input els.push(ipts[i]); // add it to the els array } } f.els = els; // set the globally accessible f.els to the finished array of text inputs } if(f.els){ // if we already had the array of text inputs or just created it i = f.els.length - 1; // set i equal to the number of text inputs for now for (i; i > -1; --i){ // for each text input // if this is the one keypressed & there's one that follows it // set m (from above) to the one that follows it for now: if(f.els[i] === t && (m = f.els[i - 1])){ m.focus(); // and give the one that follows it focus } } } } // end next() function // if the element keypressed has an id of inqty# or outqty# & the key was ENTER // set m (from above) to an array whose [2] index is the # part of that for now, // and do the next bracketed block: if((m = re.exec(t.id)) && e.keyCode === 13){ e.returnValue = false; // for IE this function will now return false when it ends. All others - this is a flag for later use // with the reference we have to the # part of the element keypressed, perform the subtraction & output // the result to the varqty# id element: t.form.elements['varqty' + m[2]].value = t.form.elements['inqty' + m[2]].value - t.form.elements['outqty' + m[2]].value; // if the input keypressed was not inqty# or outqty# and not the submit button and the key was ENTER // execute the following bracketed code block: } else if (t.type && e.keyCode === 13 && t.type.toLowerCase() !== 'submit') { // for IE this function will now return false (cancel the default action) when it ends. // All others and IE - this is a flag for later use: e.returnValue = false; } if(!e.returnValue){ // if our flag is false (this includes IE and all others) execute the following bracketed code next(); // highlight the next text input if any (see next() function above for details) // if the browser supports canceling the default action of the keypress // with the preventDefault method, do so: if(e.preventDefault){e.preventDefault();} } // probably meaningless at this point, but if some browser doesn't yet know what to return // and therefore what to do with the default action of the keypress, this will tell it: return e.returnValue; } </script>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
rhodarose (12-15-2010)
Bookmarks