在&lt;&lt; <here doc =“”

时间:2017-10-06 07:23:57

标签: php

=“”

中的粘性表单我试图在一个HERE文档中粘贴一个html表单是在PHP。我已经让文本字段变得粘滞并且工作得很好,但我无法获得复选框,下拉菜单和单选按钮以保持粘性。我试过设置一个变量$ checked =“checked”;但这只是检查乞讨时的方框,一旦表格提交,支票就会消失。

<?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 个答案:

没有答案