使用cookie下载php中的列表

时间:2014-06-25 04:24:29

标签: javascript php cookies

<?php
$i=1;
//echo '<form id="form1" name="form1" method="post"  action="<?PHP $_SERVER ['PHP_SELF' ]
echo '<form>'; 
echo "<select name='dropdown' id=$i onchange='myFunction()'><option>Select one...</option>";

echo '<option value="horse">horse</option>';
echo '<option value="hor">hor</option>';


echo '</select>';

    echo '</form>';
    $i++;
    echo '<form>'; 
    echo "<select name='dropdown' id=$i onchange='myFunction()'><option>Select one...</option>";

    echo '<option value="por">por</option>';
    echo '<option value="voi">voi</option>';
    echo '</select>';
    echo '</form>';
    echo '<p id="demo"></p>
    <script type ="text/javascript">

    function myFunction()
    {
        var k=2;
        var x=document.getElementById(k);
        var y=x.options[x.selectedIndex];
        if(y){
            document.cookie=\'name=\'+y.value;
            alert(y.value);
        }

    }
    </script>';
    $var=$_COOKIE["name"];
    echo $var;
    ?>

0 个答案:

没有答案