无法提交表格

时间:2013-08-13 20:15:12

标签: php html

我正在使用php和html创建一个网站,其中包含一些功能。目前我使用.change和.load事件进行各种提取和显示。我用过

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

提交并显示php结果,这是一个表单。但是当我在表单中点击提交时它什么也没做(我可以看到!)。

表单提交的结果应显示“完成!”

在Job Select上执行的代码是

$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>";

doeditjob.php的代码只是echo "Done!";

1 个答案:

答案 0 :(得分:1)

您在加载功能中发送了错误的内容。变化:

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

到此:

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

注意.html().val()

的区别

当您执行第一个时,您会收到以下javascript错误(请查看您的控制台)

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>

修改:您的选择也没有值。这是他们呈现的方式:

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

我认为问题的一部分是你的HTML标记。尝试在表格外面添加表单标签,然后再将其清理一遍,然后再试一次