Derek Hutchinson
Derek Hutchinson

Reputation: 55

Unable to submit form

I'm creating a website using php and html with a few few functions. At the moment I am using a .change and .load event to do various fetching and displaying. I've used

$("#jobtable").load("editjob.php?jobchose=" + $("#jobnoselect").val());

to submit and display the php result, which is a form. However when I hit submit in the form it does nothing (That I can see!).

The result of the form submission should display "Done!"

Code executed on Job Select is

$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
$selected = mysql_select_db("a9629416_btstats", $dbhandle) or die("Could not select examples");
$jobchose = mysql_real_escape_string($_GET['jobchose']);

$query = "SELECT * FROM MasterJobTable WHERE JobNo='$jobchose'";

$result = mysql_query($query);
    $result2 = mysql_query($query);
    $current = mysql_fetch_array($result2);

    echo "<table>";
    echo "<tr>";
    echo "<td colspan=\"13\">Current: <h7>" . $current['JobNo'] . "</h7></td>";
    echo "</tr>";
    echo "<tr>";
    echo    "<td>NI7S</td>
            <td>NI7W</td>
            <td>NI7F</td>
            <td>NI1V</td>
            <td>NI7T</td>
            <td>NI7J</td>
            <td>NI7K</td>
            <td>NI7L</td>
            <td>NI7Y</td>
            <td>NI1P</td>
            <td>NI8T</td>
            <td>NI9K</td>
            <td>NI6M</td>";
    echo "</tr>";
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo        "<td>" . $row['NI7S'] . "</td>
            <td>" . $row['NI7W'] . "</td>
            <td>" . $row['NI7F'] . "</td>
            <td>" . $row['NI1V'] . "</td>
            <td>" . $row['NI7T'] . "</td>
            <td>" . $row['NI7J'] . "</td>
            <td>" . $row['NI7K'] . "</td>
            <td>" . $row['NI7L'] . "</td>
            <td>" . $row['NI7Y'] . "</td>
            <td>" . $row['NI1P'] . "</td>
            <td>" . $row['NI8T'] . "</td>
            <td>" . $row['NI9K'] . "</td>
            <td>" . $row['NI6M'] . "</td>";
echo "</tr>";
echo "<br />";
}
echo "<table>";
echo "<tr>";
echo "<td colspan=\"5\">New Standard Units on Job number: <h7>" . $current['JobNo'] . "</h7></td>";
echo "</tr>";
echo "<tr>";
echo        "<td>NI7S</td>
            <td>NI7W</td>
            <td>NI7F</td>
            <td>NI1V</td>
            <td>NI7T</td>";
echo "</tr>";
echo "<form action=\"doeditjob.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"jobtoedit\" value=\"" . $current['JobNo'] . "\">";
echo "<tr>";
echo        "<td><input type=\"text\" name=\"NI7S\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7S'] . "\"></td>
            <td><input type=\"text\" name=\"NI7W\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7W'] . "\"></td>
            <td><input type=\"text\" name=\"NI7F\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7F'] . "\"></td>
            <td><input type=\"text\" name=\"NI1V\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI1V'] . "\"></td>
            <td><input type=\"text\" name=\"NI7T\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7T'] . "\"></td>";
echo "</tr>";
echo "</table>";
echo "<table>";
echo "<tr>";
echo "<td colspan=\"8\">New DFE Units on Job number: <h7>" . $current['JobNo'] . "</h7></td>";
echo "</tr>";
echo "<tr>";
echo        "<td>NI7J</td>
            <td>NI7K</td>
            <td>NI7L</td>
            <td>NI7Y</td>
            <td>NI1P</td>
            <td>NI8T</td>
            <td>NI9K</td>
            <td>NI6M</td>";
echo "</tr>";
echo "<tr>";
echo        "<td><input type=\"text\" name=\"NI7J\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7J'] . "\"></td>
            <td><input type=\"text\" name=\"NI7K\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7K'] . "\"></td>
            <td><input type=\"text\" name=\"NI7L\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7L'] . "\"></td>
            <td><input type=\"text\" name=\"NI7Y\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI7Y'] . "\"></td>
            <td><input type=\"text\" name=\"NI1P\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI1P'] . "\"></td>
            <td><input type=\"text\" name=\"NI8T\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI8T'] . "\"></td>
            <td><input type=\"text\" name=\"NI9K\"  maxlength=\"4\" size=\"4\" value=\"" . $current['NI9K'] . "\"></td>
            <td><input type=\"text\" name=\"NI6M\" maxlength=\"4\" size=\"4\" value=\"" . $current['NI6M'] . "\"></td>";
echo "</tr>";
echo "</table>";
echo "<input type=\"submit\" value=\"Update Job\">";
echo "</form>";

And the code to the doeditjob.php is just echo "Done!";

Upvotes: 1

Views: 135

Answers (1)

Hanlet Esca&#241;o
Hanlet Esca&#241;o

Reputation: 17380

You are sending the wrong stuff in the Load function. Change:

$("#jobnoselect").change(function() 
{
   $("#jobtable").load("editjob.php?jobchose=" + $("#jobnoselect").html());
});

to this:

$("#jobnoselect").change(function() 
{
   $("#jobtable").load("editjob.php?jobchose=" + $("#jobnoselect").val());
});

Notice the difference in .html() and .val()

when you do the first one you get the following javascript error (look at your console)

Uncaught Error: Syntax error, unrecognized expression: <option>Please Select Job Number</option><option>fghdfghdfghfg</option><option>fdshsgfh</option><option>gjdfgj</option><option>dfhs</option><option>cfbdfgdfg</option>

Edit: Your select do not have a value either. This is how they render:

    <select id="jobnoselect">    
   <option>Please Select Job Number</option>
    <option>jhkushd</option>
    <option>uiuikuyi</option>
    <option>test</option></select>

I think part of the problem is your HTML Markup. Try to have the form tag outside the table, and clean it up a little more, and try again

Upvotes: 1

Related Questions