dshfjsh_5455 2017-10-06 07:23
浏览 69

粘贴形式在<<< HERE doc

I am trying to make a html form sticky inside of a HERE doc that is in php. I have gotten text fields to be sticky and work just fine, but i am having trouble getting checkboxes, dropdowns, and radio buttons to stay sticky. Ive tried setting a variable $checked = "checked"; but that just checks the box at the begging and once the form is submitted the check goes away.

<?php
echo <<<HERE
        <p>
            <input type="radio" name="mediaType" id="MPEG audio file" value="MPEG audio file"
             if ($type == "MPEG audio file") {echo "checked"}
             >
             <label for="MPEG audio file">MPEG audio file</label>
            <input type="radio" name="mediaType" id="Protected AAC audio file" value="Protected AAC audio file"
             if ($type == "Protected AAC audio file") {echo "checked";}
             >
             <label for="Protected AAC audio file">Protected AAC audio file</label>
            <input type="radio" name="mediaType" id"Protected MPEG-4 video file" value="Protected MPEG-4 video file"
             if ($type == "Protected MPEG-4 video file") {echo "checked";}
             >
             <label for="Protected MPEG-4 video file">Protected MPEG-4 video file</label>
            <input type="radio" name="mediaType" id="Purchased AAC audio file" value="Purchased AAC audio file"
             if ($type == "Purchased AAC audio file") {echo "checked";}
             >
             <label for="Purchased AAC audio file">Purchased AAC audio file</label>
            <input type="radio" name="mediaType" id="AAC audio file" value="AAC audio file"
             if ($type == "AAC audio file") {echo "checked";}
             >
             <label for="AAC audio file">AAC audio file</label>
             <span class='error'>$errorMediaType</span>
        </p>
    <p>
            <input type="checkbox" name="playlists" id="party" value="party"
                if ($playlists == "party") {echo "checked";}
             >
              <label for="Party">Party</label>
            <input type="checkbox" name="playlists" id="calm" value="calm"
                if ($playlists == "calm") {echo "checked";}
             >
              <label for="Calm">Calm</label>
            <input type="checkbox" name="playlists" id="gaming" value="gaming"
                if ($playlists == "gaming") {echo "checked";}
             >
              <label for="Gaming">Gaming</label>
            <input type="checkbox" name="playlists" id="travel" value="Travel"
                if ($playlists == "travel") {echo "checked";}
             >
              <label for="Travel">Travel</label>
            <input type="checkbox" name="playlists" id="oldies" value="oldies" 
                if ($playlists == "oldies") {echo checked}
             >
              <label for="Oldies">Oldies</label>
              <span class='error'>$errorPlaylists</span>
        </p>
    <p>
             <select name="genre" id="genre">
                    <option value="Select a Genre"
                      if ($genre=="Select a Genre") {echo "selected";}>Select a Genre</option>
                    <option value="Rock"
                      if ($genre=="Rock") { echo "selected";}>Rock</option>
                    <option value="Jazz"
                    if ($genre=="Jazz") { echo "selected";}>Jazz</option>
                    <option value="Metal"
                    if ($genre=="Metal") { echo "selected";}>Metal</option>
                    <option value="Alternative and Punk"
                    if ($genre=="Alternative and Punk") {echo "selected";}>Alternative and Punk</option>
                    <option value="Jazz"
                    if ($genre=="Jazz") { echo "selected";}>Jazz</option>
                    <option value="Blues"
                    if ($genre=="Blues") { echo "selected";}>Blues</option>
                    <option value="Latin"
                    if ($genre=="Latin") { echo "selected";}>Latin</option>
                    <option value="Reggae"
                    if ($genre=="Reggae") { echo "selected";}>Reggae</option>
                    <option value="Pop"
                    if ($genre=="Pop") { echo "selected";}>Pop</option>
                    <option value="Soundtrack"
                    if ($genre=="Soundtrack") { echo "selected";}>Soundtrack</option>
            </select> 
            <span class='error'>$errorGenre</span>
        </p>
    <p>
            <label for="tracks">Number of Tracks:</label>
            <input type="text" name="tracks" id="tracks" value=$tracks>
            <span class='error'>$errorTracks</span>
        </p>
    <p>
            <input type="submit" name="submit" value="Add">
        </p>
    </form>
HERE;
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 iOS开发关于快捷指令截屏后如何将截屏(或从截屏中提取出的文本)回传给本应用并打开指定页面
    • ¥15 unity连接Sqlserver
    • ¥15 图中这种约束条件lingo该怎么表示出来
    • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
    • ¥15 流式socket文件传输答疑
    • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
    • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
    • ¥15 win10,这种情况怎么办
    • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
    • ¥100 在连接内网VPN时,如何同时保持互联网连接