Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如果出现错误,则在提交后显示新添加的行_Php_Javascript_Html - Fatal编程技术网

Php 如果出现错误,则在提交后显示新添加的行

Php 如果出现错误,则在提交后显示新添加的行,php,javascript,html,Php,Javascript,Html,我使用这个Javascript在已经包含4行的表preq中添加行。问题是,当我使用这个Javascript添加行时,行被正确地添加到表单上,但是如果表单上出现错误,并且表单被重新加载,那么新添加的行将不可见,并且我还希望行中输入的文本可见 <table align="left" id="preq" style="display: none;"> <tr> </tr>

我使用这个Javascript在已经包含4行的表
preq
中添加行。问题是,当我使用这个Javascript添加行时,行被正确地添加到表单上,但是如果表单上出现错误,并且表单被重新加载,那么新添加的行将不可见,并且我还希望行中输入的文本可见

<table align="left" id="preq" style="display: none;">
                <tr>
                                </tr>
                                    <tr>
                                    <th align="left"><label id="Label1"> Kind of Work </label></th>
                                    <th align="left"><label id="Label1"> Name Of The Client </label></th>
                                    <th align="left"><label id="Label1">Name of Firm / Organisation </label></th>
                                    </tr>
            <tbody>

            <!--4 rows alredy present here-->
            </tbody>
    <tr><td colspan="3"><input type="button" class="button" value="Add Kind of Work" onclick="addrow()"/></td></tr>

            </table>
javascript

<script type="text/javascript">
            var counter = 5;
            function addrow()
            {
                if (counter > 10)
                {
                    alert("Only 10 Kind of Works are allowed");
                return false;
                }
            $('#preq > tbody:last').append('<tr><td><input title="Enter Kind Of work" readonly="readonly" onclick="if(this.value!=\'\'){this.value=\'\';opendrop();}else{opendrop();}" id="other_work' + counter + '" name="other_work' + counter + '" type="text" size="30" onclick="opendrop()" <?php if (isset($errors)) { echo 'value="'.htmlentities(@$_POST['other_work' + counter + '']).'"'; } ?>></td><td><input name="client_name' + counter + '" type="text" id="client_name' + counter + '" size="40"/></td><td><input name="firm_name' + counter + '" type="text" id="firm_name' + counter + '" size="40"/></td></tr>');
                counter++;
            }
            </script>
<table align="left" id="preq" style="display: none;">
                <tr>
                                </tr>
                                    <tr>
                                    <th align="left"><label id="Label1"> Kind of Work </label></th>
                                    <th align="left"><label id="Label1"> Name Of The Client </label></th>
                                    <th align="left"><label id="Label1">Name of Firm / Organisation </label></th>
                                    </tr>
            <tbody>

            <!--4 rows alredy present here-->
            </tbody>
    <tr><td colspan="3"><input type="button" class="button" value="Add Kind of Work" onclick="addrow()"/></td></tr>

            </table>

var计数器=5;
函数addrow()
{
如果(计数器>10)
{
警告(“仅允许10种工程”);
返回false;
}

$(“#preq>tbody:last”)。追加(“尝试添加
else
,因此,只有在没有错误时才添加行(在
if()
上会发出警报)

<table align="left" id="preq" style="display: none;">
                <tr>
                                </tr>
                                    <tr>
                                    <th align="left"><label id="Label1"> Kind of Work </label></th>
                                    <th align="left"><label id="Label1"> Name Of The Client </label></th>
                                    <th align="left"><label id="Label1">Name of Firm / Organisation </label></th>
                                    </tr>
            <tbody>

            <!--4 rows alredy present here-->
            </tbody>
    <tr><td colspan="3"><input type="button" class="button" value="Add Kind of Work" onclick="addrow()"/></td></tr>

            </table>
if(计数器>10){
警告(“仅允许10种工程”);
返回false;
}否则{

$('#preq>tbody:last')。追加(“如果您希望新添加的行即使在重新加载表单后仍保持不变,则需要将其保存到数据库中,否则每次重新加载页面时,数据都将丢失。

重新加载表单时,新添加的行仍不可见,如果表单出现错误,请查看服务器端编程语言(PHP)之间的差异。”和客户端编程语言(JavaScript),它是一个提交表单,所以如果在点击提交按钮后表单上出现错误,我希望新添加的行保持不变
<table align="left" id="preq" style="display: none;">
                <tr>
                                </tr>
                                    <tr>
                                    <th align="left"><label id="Label1"> Kind of Work </label></th>
                                    <th align="left"><label id="Label1"> Name Of The Client </label></th>
                                    <th align="left"><label id="Label1">Name of Firm / Organisation </label></th>
                                    </tr>
            <tbody>

            <!--4 rows alredy present here-->
            </tbody>
    <tr><td colspan="3"><input type="button" class="button" value="Add Kind of Work" onclick="addrow()"/></td></tr>

            </table>