HTML5 Textarea占位符作为表单上的值提交

时间:2014-11-17 09:27:48

标签: php html5 forms placeholder

大家早上好。我已经在SO和Google工作了一个多小时,试图弄清楚我有一种感觉真的是一个愚蠢的问题并且很容易解决,我似乎无法到达那里。

我有一个PHP页面,其中包含表单,按钮等。在textarea上,我使用“占位符”属性向用户询问请求的状态(如果有)。当我提交表单时,占位符文本显示为表单字段的值,如果没有输入任何内容(不是必填字段)。

表格的PHP来源:

<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>" class="form" id="allreqform">
        <fieldset class="fieldset">
            <h3 style="text-align: center;">All New Requests</h3>
            <table class="table" id="curricreqtable" style="margin-left: auto; margin-right: auto; margin-bottom: 10px;">
                <tr style="text-align: center;">
                    <th class="th">&nbsp;ID&nbsp;</th>
                    <th class="th">&nbsp;Home Visitor&nbsp;</th>
                    <th class="th">&nbsp;Language&nbsp;</th>
                    <th class="th">&nbsp;Year&nbsp;</th>
                    <th class="th">&nbsp;Packet/Week&nbsp;</th>
                    <th class="th">&nbsp;Book Title&nbsp;</th>
                    <th class="th">&nbsp;Qty&nbsp;</th>
                    <th class="th">&nbsp;Status&nbsp;</th>
                </tr>
                <tr class="noprint" style="text-align: center;">
                    <th class="th" colspan="8">&nbsp;Status Buttons&nbsp;</th>
                </tr>
                <tr class="noprint" class="noprint" style="text-align: center;">
                    <th class="th" colspan="8">&nbsp;Request Notes&nbsp;</th>
                </tr>

                <?php
                $getcurricreqsummaryquery = "<redacted>;";
                $getcurricreqsummaryqueryresults = $mysqli->query($getcurricreqsummaryquery);

                $rownum = 0;
                while ($row = $getcurricreqsummaryqueryresults->fetch_object()) {
                    $req = $rownum;
                    $datereq = $row->curricrequestDateReq;
                    $hvid = $row->curricrequestHVID;
                    $langid = $row->curricrequestCurricLanguage;
                    $yearid = $row->curricrequestCurricYearID;
                    $pckt = $row->curricrequestCurricPacket;
                    $book = $row->curricrequestBookTitle;
                    $status = $row->curricrequestCAStatus;
                    $notes = $row->curricrequestCANotes;
                    $reqcnt = $row->PktSum;

                    $findhvnamequery = "<redacted>";
                    $findhvnamequeryresults = $mysqli->query($findhvnamequery);
                    $row2 = $findhvnamequeryresults->fetch_object();
                    $hvname = $row2->HVNAME;

                    ?>
                    <tr style="text-align: center;">
                    <td class="<?= $class ?>"><?= $rownum ?></td>
                    <input type="hidden" name="datereq<?= $rownum ?>" value="<?= $datereq ?>" />
                    <td class="<?= $class ?>"><?= $hvname ?></td>
                    <input type="hidden" name="hvid<?= $rownum ?>" value="<?= $hvid ?>" />
                    <td class="<?= $class ?>"><?= $lang ?></td>
                    <td class="<?= $class ?>">Y<?= $yearid ?></td>
                    <td class="<?= $class ?>"><?= $pcktdisp ?></td>
                    <input type="hidden" name="pckt<?= $rownum ?>" value="<?= $pckt ?>" />
                    <td class="<?= $class ?>"><?= $book ?></td>
                    <td class="<?= $class ?>"><?= $reqcnt ?></td>
                    <td class="<?= $class ?>"><?= $statusdisp ?></td>
                    </tr>
                    <tr class="noprint" style="text-align: center;">
                        <td colspan="8" class="<?= $class ?>"><input class="button" type="submit" name="pend<?= $rownum ?>" id="pend<?= $rownum ?>" value="Pending" /> <input class="button" type="submit" name="comp<?= $rownum ?>" id="comp<?= $rownum ?>" value="Complete" onclick="return confirm('By clicking the OK button, you are digitally signing that you have completed this request. Are you ready to confirm?')" /> <input class="button" type="submit" name="part<?= $rownum ?>" id="part<?= $rownum ?>" value="Partial" /> <input class="button" type="submit" name="inco<?= $rownum ?>" id="inco<?= $rownum ?>" value="Inomplete" /></td>
                    </tr>
                    <tr class="noprint" style="text-align: center;" class="<?= $class ?>">
                        <?php
                        print "<input type=\"hidden\" name=\"req[$rownum]\" value=\"$rownum\" />";
                        ?>
                    <input type="hidden" name="req<?= $rownum ?>" value="<?= $rownum ?>" />
                        <td colspan="8"><textarea cols="88" rows="4" name="comm<?= $rownum ?>" style="width: 725px; height: 65px; border: 1px solid black; float: left; margin-left: 10px; margin-right: 10px; margin-bottom: 5px; margin-top: 5px;" placeholder="What's up with this request?" wrap="hard"></textarea></td>
                    </tr>
                    <?php
                }
                ?>
            </table>
            <input type='hidden' value='1' name='submitted' />
            <input type="hidden" name="section" value="allreqs">
        </fieldset>
    </form>

通过“foreach”和自定义日志记录代码记录所有$ _POST变量的结果:

<non-relevant output redacted>
[2014/11/17 03:24:26]Key: datereq10, Value: 2014-11-02
[2014/11/17 03:24:26]Key: hvid10, Value: 4
[2014/11/17 03:24:26]Key: pckt10, Value: 61
[2014/11/17 03:24:26]Key: comp10, Value: Complete
[2014/11/17 03:24:26]Key: req10, Value: 10
[2014/11/17 03:24:26]Key: comm10, Value: What's up with this request?
<non-relevant output redacted>

任何人都有任何建议可以分享吗?我非常感激!!

TheJester1977

0 个答案:

没有答案