duanpo7282 2014-11-17 09:27
浏览 54

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

Good morning all. I've been on SO and Google for well over an hour trying to figure something out that I have a feeling is really a stupid problem and easily solvable, I just can't seem to get there.

I have a PHP page that has a form, buttons, etc. On the textarea, I am using the "placeholder" attribute to ask the user for a status on the request, if any. When I submit the form, the placeholder text shows up as the value for the form field, if nothing is entered (not a required field).

PHP Source For Form:

<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>

Results of logging all $_POST variables through "foreach" and custom logging code:

<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>

Anyone have any advice they can share on this? I would appreciate it greatly!!

TheJester1977

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
    • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)