php included form acting strangley with Firefox - php

For some reason when I call a function to create a form, the drop down menus aren't sticky and the browser forces users to click into the first text field and tab through the rest. It won't let them mouse through the fields. This is only happening in FF, not IE or Chrome. The forms I'm including are just basic html and only php pages I include are doing this.
Here is one function:
function addNoteUI($keyword) {
echo "<div id='search_result_right'>";
echo "<center><div id='enter_note_header'>Assign a Salesperson</div></center><p>";
echo "<form id='response' action='notes_add.php' method='post'>";
echo "<label for='mod_num'>MOD Initials: <label>";
echo "<input type='text' name='mod_num' size='2' maxlength='4'><p>";
echo "<label for='sales_num'>Assigned to Sales Person: <label>";
echo "<input type='text' name='sales_num' size='2' maxlength='4'><p>";
echo "<input type='hidden' name='question_num' value='$keyword'>";
echo "<label for='response'>Note</label><br>";
echo "<textarea name='response' cols='30' rows='7 maxlength='510'></textarea><p>";
echo "<input type='submit' value='Assign'>";
echo "</form>";
echo "</div>";
Here is the other:
function changeDept() {
include 'ask_search.php';
echo "<div id='search_result'>";
echo "<form action='change_dept.php' method='post'>";
echo "<label for='current_num'>Enter the Question Number to be Changed: <label>";
echo "<input type='text' name='current_num' size='4'><p>";
echo "<label for='store'>Select New Store/Department: <label>";
echo "<select name='store'>";
echo "<option>Please Select</option>";
echo "<option value='Albany'>Sales (Albany Store)</option>";
echo "<option value='Saratoga'>Sales (Saratoga Store)</option>";
echo "<option value='Web Sales'>Sales (TaftFurniture.com)</option>";
echo "<option value='Financing'>Financing</option>";
echo "<option value='Customer Service'>Customer Service</option>";
echo "<option value='Delivery'>Delivery</option>";
echo "<option value='HR'>Human Resources</option>";
echo "<option value='Web Contact'>Website Comment</option>";
echo "<input type='submit' value='Change' id='dropdown'>";
echo "</select></form></div>";
}
Thanks in advance.

Your labels are not closing properly:
echo "<label for='mod_num'>MOD Initials: <label>";
Should be:
echo "<label for='mod_num'>MOD Initials: </label>";
Also, in the second example, you have an input inside the select. The input must be outside:
echo "<option value='Web Contact'>Website Comment</option>";
echo "<input type='submit' value='Change' id='dropdown'>";
echo "</select></form></div>";
Should be:
echo "<option value='Web Contact'>Website Comment</option>";
echo "</select>";
echo "<input type='submit' value='Change' id='dropdown'></form></div>";
And another one, you're not closing your P tags:
echo "<input type='text' name='mod_num' size='2' maxlength='4'><p>";
Should be:
echo "<p><input type='text' name='mod_num' size='2' maxlength='4'></p>";
Try to be more careful with your tags. Some browsers are more forgiving about malformed HTML, but others are not.

Related

Label tag is not moving the form structure in line

The label tag has the right syntax however the form structure is not aligned well the way I want it.I also put id as well
echo "<form action='getregister.php' method='post'>";
echo "<fieldset >";
echo "<legend>Register</legend>";
echo "<input type='hidden' name='submitted' id='submitted' value='1'/>";
echo "<label for='First_name'>First Name: </label>";
echo "<input type='text' name='U_fname' id='First_name' value=''><br>";
echo "<label for='Last_name'>Last Name: </label>";
echo "<input type='text' name='U_sname' id='Last_name' value=''><br>";
echo "<label for='Address' >Address: </label>";
echo "<input type='text' name='U_address' id='Address' value=''><br>";
echo "<label for='Postcode' >Postcode: </label>";
echo "<input type='text' name='U_postcode' id='Postcode' value=''><br>";
echo "<label for='Telno' >Tel No: </label>";
echo "<input type='text' name='U_telNo' id='Telno' value=''><br>";
echo "<label for='Email' >Email Address: </label>";
echo "<input type='email' name='U_email' id='Email' value=''><br>";
echo "<label for='password' >Password:</label>";
echo "<input type='password' name='U_password' id='password' value=''><br>";
echo "<label for='passwords' >Confirm Password:</label>";
echo "<input type='password' name='U_confirmPassword' id='passwords' value=''><br>";
echo "<input type='submit' name='Submit' value='Register' />";
echo "<button type='reset' value='Reset'>Clear form</button>";
echo "</fieldset>";
echo "</form>";
Try like this:
echo "<form action='getregister.php' method='post'>";
echo "<fieldset >";
echo "<legend>Register</legend>";
echo "<input type='hidden' name='submitted' id='submitted' value='1'/>";
echo "<table>";
echo "<tr>";
echo "<td><label for='First_name' >First Name: </label></td>";
echo "<td><input type='text' name='U_fname' value=''></td>";
echo "</tr>";
echo "<tr>";
echo "<td><label for='Last_name'>Last Name: </label></td>";
echo "<td><input type='text' name='U_sname' id='Last_name' value=''>";
echo "</tr>";
echo "<table>";
echo "</fieldset>";
echo "</form>";

PHP Basket quantity variable

I am trying to create a php page where the materials from database are populated. Users should be able to enter the quantity next to the item they wish to order and I have created a qty text field for this
<?php
session_start();
include("db.php");
$pagename="Order Material";
echo "<html>";
echo "<title>".$pagename."</title>";
echo "<h2>".$pagename."</h2>";
include ("detectlogin.php");
echo "<link rel=stylesheet type=text/css href=mystylesheet.css>";
$sql="select * from material";
$result=mysqli_query($con, $sql) or die(mysqli_error($con));
echo "<table border=1>";
echo "<tr>";
echo "<th>Material Name</th>";
echo "<th>Material Description</th>";
echo "<th>Toxicity Level</th>";
echo "</tr>";
while ($arraymaterials=mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$arraymaterials['materialName']."</td>";
echo "<td>".$arraymaterials['materialDescrip']."</td>";
echo "<td>".$arraymaterials['materialToxicity']."</td>";
echo "<td>Enter Quantity</td>";
echo "<td><input type=text name=qty value=qty size=5></td>";
echo "<form action=request_material.php method=post>";
echo "<input type=hidden name=materialcode value=".$arraymaterials['materialCode'].">";
echo "<td><input type=submit value='Request'></td>";
echo "</form>";
echo "</tr>";
}
echo "</table>";
?>
However, I cannot successfully post the value of qty on to the next page even though I have $qty=$_POST['qty']; on my request_material.php. Do you know why this value entered in the qty field cannot be posted onto the request_material.php page? Do I need a session variable?
thanks
Because input tag name="qty" is outside the form tag
echo "<td><input type=text name=qty value=qty size=5></td>";// outside form tag
echo "<form action=request_material.php method=post>";
echo "<input type=hidden name=materialcode value=" . $arraymaterials['materialCode'] . ">";
echo "<td><input type=submit value='Request'></td>";
echo "</form>";
You need to add it inside your form tag as
echo "<form action=request_material.php method=post>";
echo "<td><input type=text name=qty value=qty size=5></td>";// add inside it
echo "<input type=hidden name=materialcode value=".$arraymaterials['materialCode'].">";
echo "<td><input type=submit value='Request'></td>";
echo "</form>";
Please try this: I have updated the code:
echo "<table border=1>";
echo "<tr>";
echo "<th>Material Name</th>";
echo "<th>Material Description</th>";
echo "<th>Toxicity Level</th>";
echo "</tr>";
if(mysqli_num_rows($result)>0)
{
echo "<form action=request_material.php method=post>";
while ($arraymaterials=mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$arraymaterials['materialName']."</td>";
echo "<td>".$arraymaterials['materialDescrip']."</td>";
echo "<td>".$arraymaterials['materialToxicity']."</td>";
echo "<td>Enter Quantity</td>";
echo "<td><input type='text' name='qty[]' value='qty' size=5></td>";
echo "<input type=hidden name='materialcode[]' value=".$arraymaterials['materialCode'].">";
echo "<td><input type=submit value='Request'></td>";
echo "</tr>";
}
echo "</form>";
}
echo "</table>";
In request_material.php check value of $qty.It will be an array.for more details print_r($_POST) in request_material.php

Save button for each row in the table. PHP MYSQL

Please help, each row in the table has save button for editing/adding content. I have 3 textboxes in each row,PersoninCharge,PIC_Comments and Status. The user can add/edit these textboxes whenever they click the save button on that particular row. The problem is, whenever I add/edit data in one row, the save button can't read what particular row I edited.
The save button is perfectly running if I searched the invoice number first, but what I want is to directly edit/add the data in each row without searching it first.
Here's the code:
For the table:
<?php
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
echo"<tr class=output2>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>$row[6]</td>";
echo "<td>$row[7]</td>";
echo "<td>$row[8]</td>";
echo "<td>$row[9]</td>";
echo "<td>$row[10]</td>";
echo "<td>$row[11]</td>";
echo "<td>$row[12]</td>";
echo "<td><input type='text' name='pic' value='$row[17]'></td>";
echo "<td><input type='text' name='comt' value='$row[18]'></td>";
echo "<td><input type='text' name='stat' value='$row[19]'></td>";
echo "<td><form name='update' method='POST'><input type='submit' name='save_btn' value='SAVE' style='font-size:1em;'/></form></td>";
echo "<td><input type='hidden' name='idtxt' value='$row[0]'/></td>";
echo "</tr>";
}
}
else
{
echo '<h3>No result found! </h3><br>';
}
$con->close();
For Save button:
if(isset($_POST['save_btn']))
{
$query2="UPDATE invalid_invoice SET UpdateBy='".$_SESSION['login_user']."', UpdateDateTime=NOW(), PersoninCharge='".$_POST['pic']."', PIC_Comments='".$_POST['comt']."', Status='".$_POST['stat']."' WHERE ID='".$_POST['idtxt']."'";
$con->query($query2);
$con->close();
echo '<h3 class="datasuccess">Data successfully added!</h3>';
}
I have edited your form. please have a look
<?php
if (mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
echo"<form name='update' method='POST'><tr class=output2>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>$row[6]</td>";
echo "<td>$row[7]</td>";
echo "<td>$row[8]</td>";
echo "<td>$row[9]</td>";
echo "<td>$row[10]</td>";
echo "<td>$row[11]</td>";
echo "<td>$row[12]</td>";
echo "<td><input type='text' name='pic' value='$row[17]'></td>";
echo "<td><input type='text' name='comt' value='$row[18]'></td>";
echo "<td><input type='text' name='stat' value='$row[19]'></td>";
echo "<td><input type='submit' name='save_btn' value='SAVE' style='font-size:1em;'/></td>";
echo "<td><input type='hidden' name='idtxt' value='$row[0]'/></td>";
echo "</tr></form>";
}
}
else
{
echo '<h3>No result found! </h3><br>';
}
$con->close();

track change in an array then submit the array to the same page

I have the following php code (I omitted the irrelevant part of code):
<?php
echo "<form action=$_SERVER[PHP_SELF] method=\"POST\">";
echo "<table>";
for ($i=0;$i<$num_rows;$i+=1) {
echo "<tr>";
echo "<td align=center>$variable1[$i]</td>";
echo "<td align=center>$variable2[$i]</td>";
echo "<td align=center><input type=\"text\" name=\"variable3[$i]\" value=\"$variable3[$i]\" /></td></tr>";
echo "<input type=\"hidden\" name=\"variable1[$i]\" value=\"$variable1[$i]\">";
echo "<input type=\"hidden\" name=\"variable2[$i]\" value=\"$variable1[$i]\">";
echo "<input type=\"hidden\" name=\"variable3[$i]\" value=\"$variable1[$i]\">";
}
echo "<tr><td colspan=\"3\"><input name=\"action\" type=\"submit\" value=\"Update\"></td></tr>";
echo "</table>";
echo "</form>";
?>
I want to pass the variables through POST method to the same page. The code retrieves data from the database and lists it in a table. However, I want to be able to manually modify variable3 and submit the array after I do this. The problem is that the array is submitted before I modify the variable3. How can I submit the array with the value of variable3 modified? How can I check if variable3 was modified and do the submitting afterwards? Thanks.
delete line 11 like this
<?php
echo "<form action=$_SERVER[PHP_SELF] method=\"POST\">";
echo "<table>";
for ($i=0;$i<$num_rows;$i+=1) {
echo "<tr>";
echo "<td align=center>$variable1[$i]</td>";
echo "<td align=center>$variable2[$i]</td>";
echo "<td align=center><input type=\"text\" name=\"variable3[$i]\" value=\"$variable3[$i]\" /></td></tr>";
echo "<input type=\"hidden\" name=\"variable1[$i]\" value=\"$variable1[$i]\">";
echo "<input type=\"hidden\" name=\"variable2[$i]\" value=\"$variable1[$i]\">";
}
echo "<tr><td colspan=\"3\"><input name=\"action\" type=\"submit\" value=\"Update\"></td></tr>";
echo "</table>";
echo "</form>";
?>
Now you can see if it has been changed by cheking the value of $_POST['variable3'].

Render form within html table

I'm trying to render an html form within a table. The problem is I load the page with AJAX and after that the button stops working (due to the tr and td placement).
Is there any way to manage this with html, javascript, php, or css?
This is what I'm trying to accomplish:
echo "<tr id=\"$I_ID\" class=\"toggleEdit\">";
echo "<form class=\"editRow\" name=\"editRow\" action=\"\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"edit\">";
echo "<input type=\"hidden\" name=\"$thatTable\">";
echo "<input type=\"hidden\" value=\"$I_ID\" name=\"I_ID\">";
echo "<input type=\"hidden\" value=\"$row[1]\" name=\"$columns[1]\">";
echo "<td>$row[1]</td>";
for ($pointer = 2 ; $pointer < $countRows ; ++$pointer) {
echo "<td><input type=\"text\" value=\"$row[$pointer]\" name=\"$columns[$pointer]\"></td>";
}
echo "<td><input type=\"submit\" id=\"submitEdit\" value=\"submit edit\"></td>";
echo "</form>";
echo "</tr>";
And this is what works:
echo "<tr id=\"$I_ID\" class=\"toggleEdit\">";
echo "<td id=\"tdEditRow\">";
echo "<form class=\"editRow\" name=\"editRow\" action=\"\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"edit\">";
echo "<input type=\"hidden\" name=\"$thatTable\">";
echo "<input type=\"hidden\" value=\"$I_ID\" name=\"I_ID\">";
echo "<input type=\"hidden\" value=\"$row[1]\" name=\"$columns[1]\">";
echo "$row[1]";
for ($pointer = 2 ; $pointer < $countRows ; ++$pointer) {
echo "<input type=\"text\" value=\"$row[$pointer]\" name=\"$columns[$pointer]\">";
}
echo "<input type=\"submit\" id=\"submitEdit\" value=\"submit edit\">";
echo "</form>";
echo "</td>";
echo "</tr>";

Categories