组合框的第二个值不会保存AJAX MYSQL PHP

时间:2013-03-13 15:04:09

标签: php ajax

对不起之前发送的帖子,这是我的问题再次这个脚本可以保存组合框的第一个值,但第二个组合框值仍然是空的任何建议? 本准则来自http://www.99points.info/2010/06/ajax-tutorial-dynamic-loading-of-combobox-using-jquery-and-ajax-in-php/comment-page-2/#comment-18108

这是我的第一页HTML     打印“”;

    echo"<div class='both'>";

    print "School Year<br />\n";

    $sy = mysql_query("SELECT DISTINCT schoolyear
                        FROM tblaccount");

    echo"<select name='schoolyear' id = 'schoolyear'>";
    echo"<option value='' >Select</option>";
    while( $row = mysql_fetch_assoc(@$sy))
    {
        $va = $row['schoolyear'];
        if($va == '')
        {}
        else
        echo"<option value ='$va'>$va</option>";
    }
    $schoolyear = $_POST['schoolyear']; 
    echo"<button onclick='myFunction()'>Search</button>";

    echo"</select><br />\n";
    echo"</div>";
    echo"<div class='both'>";
        echo"<h4 id='show_heading'>Select Term</h4>";
        echo"<div id='show_sub_categories' align='center'>";
            echo"<img src='loader.gif' style='margin-top:8px; float:center' id='loader' alt='' />";
            echo"<br />";
                    echo"</div>";

    echo"</div>";


    print "Upload new csv by browsing to file and clicking on Upload<br />\n";

    print "File name to import:<br />\n";

    print "<input size='50' type='file' name='filename'><br />\n";


    print "<input type='submit' name='submit' value='Upload'></form>";

我的脚本也包括js.min

         $(document).ready(function() {


                $('#loader').hide();
                $('#show_heading').hide();
                $('#gobtn').hide();

                $('#schoolyear').change(function(){
                    $('#gobtn').show();
                    $('#show_sub_categories').fadeOut();
                    $('#loader').show();
                    $.post("get_chid_categories.php", {
                        schoolyear: $('#schoolyear').val(),
                    }, function(response){
                        setTimeout("finishAjax('show_sub_categories', '"+escape(response)+"')", 400);
                    });
                    return false;
                });


            });

                            function finishAjax(id, response){
                  $('#loader').hide();
                  $('#show_heading').show();
                  $('#'+id).html(unescape(response));
                  $('#'+id).fadeIn();
                } 

                function alert_id()
                {
                    if($('#sub_category_id').val() == '')
                    alert('Please select a Term.');
                    else
                    alert($('#sub_category_id').val());
                    return false;
                }

                </script>

第2页/子类别页面

 <pre>
if($_REQUEST)
{
    $id = $_REQUEST['schoolyear'];
    //echo"<script>alert('$id')</script>";
    $query = "select distinct term from tblaccount where schoolyear = '$id'";
    $results = mysql_query( $query);?>

    <form action ='Admin_activation.php' method='post'>
    <select name="sub_category"  id="sub_category_id">
    <option value="" selected="selected"></option>
    <?php
    while ($rows = mysql_fetch_assoc(@$results))
    {?>
        <option value="<?php echo $rows['term'];?>  ID='term' name='term';?>"><?php echo $rows['term'];?></option>
    <?php

    }?>
    </select>   
    </form>
    <?php

    ?>
  </pre>

0 个答案:

没有答案