1

我正在使用带有一些功能的 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!";

4

1 回答 1

1

您在 Load 函数中发送了错误的内容。改变:

$("#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 标记。尝试将表单标签放在表格之外,再清理一下,然后再试一次

于 2013-08-13T20:19:28.167 回答