使用自动填充功能自动填充相关字段不起作用?

时间:2014-04-17 16:36:40

标签: php jquery

<?php
include("authenticate.php");
session_start();
define('RESEARCH_FILES', 'http://www.scriplogix.com/wordpress/docs/');
include( "function_helper.php");
echo $_SESSION['file_url'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Scriplogix</title>
 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <script type="text/javascript"> 

        jQuery(document).ready(function(){
    $('.zipsearch').autocomplete({
      alert("dsafa");
        source:'suggest_zip.php',
        minLength:2,
        select:function(evt, ui)
        {
            // when a zipcode is selected, populate related fields in this form
            this.form.city.value = ui.item.city;
            this.form.state.value = ui.item.state;
        }
    });
});

    </script> 

<script type="text/javascript">

  var _gaq = _gaq || [];
  var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
  _gaq.push(['_require', 'inpage_linkid', pluginUrl]);
  _gaq.push(['_setAccount', 'UA-990052-4']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
<link href="css/fonts.css" rel="stylesheet" type="text/css" />
<link href="css/grid.css" rel="stylesheet" type="text/css" />
<link href="css/accordion.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

<!-- Form -->
<link rel="stylesheet" href="js/form/css/uniform.default.css" media="screen" />
<script src="js/form/js/jquery.uniform.js"></script>
<link rel="stylesheet" type="text/css" href="js/form/tagging/jquery.tagsinput.css" />
<script type="text/javascript" src="js/form/tagging/jquery.tagsinput.js"></script>
<script type='text/javascript'>
    // On load, style typical form elements
    $(function () {
        $("select, input, button").uniform();
        $('#tags_1').tagsInput({width:'420px'});
    });
</script>
<!-- // Form -->

<!-- Content Scrolling -->
<link href="css/jquery.mCustomScrollbar.css" rel="stylesheet" />
<script src="js/jquery.mCustomScrollbar.js"></script>
<script>
(function($){
    $(window).load(function(){
    $(".content").mCustomScrollbar({
    advanced:{
        updateOnContentResize: true
    }
});
});
})(jQuery);
</script>
<!-- Content Scrolling Ends -->

<script src="js/jquery.accordion.source.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    $(document).ready(function () {
    var wheight = ($(window).height());
    var height = wheight - 168;
    //alert(wheight); alert(height);
    $(".content").css("height",height);
    $('ul').accordion();
    //$("#div_1").trigger('click')
    /*if($(".grid_left").height() > 210)
    $(".grid_right").height($(".grid_left").height()-29)*/
    var lheight = height - 25;
    $(".grid_right").css("height",lheight);

    $("#asc").click(function(){
        $("#desc").removeClass("active");
        $("#asc").addClass("active");
        $("#search_order").val("asc");
    });

    $("#desc").click(function(){
        $("#asc").removeClass("active");
        $("#desc").addClass("active");
        $("#search_order").val("desc");
    });

});
</script>

<!--dropdown-->
<link href="css/jquery.selectbox.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.selectbox-0.2.js"></script>
<script type="text/javascript">
$(function () {
    $("#country_id").selectbox();
    $("#country_id1").selectbox();
});
window.onload = function(){
        $('.PopWrapper').hide();
};
var openId;
function show_visuals(id)
{
//document.getElementById(id).style.display = "block";
//$(".visual_snap").hide()
if(openId != id)
{
    $("#"+openId).hide()
}
$("#"+id).slideToggle(100);
openId = id;
}
</script>

<!-- Navigation Menu -->
<link rel="stylesheet" type="text/css" href="css/iconmenu.css" />
<script src="js/jquery-1.7.2.min.js"></script>
<script>
jQuery.noConflict();
</script>
<script src="js/iconmenu.js"></script>
<script>
ddiconmenu.docinit({ // initialize an Icon Menu
    menuid:'myiconmenu', //main menu ID
    easing:"easeInOutCirc",
    dur:500 //<--no comma after last setting
})
</script>
<!-- Navigation Menu Ends -->

<!-- Upload -->
<link rel="stylesheet" href="js/upload/dropzone.css" />
<script src="js/upload/dropzone.js"></script>

<!-- // Upload -->

</head>
<body>

<!-- Navigation Menu -->
<?php include('left-menu.php');?>
<!-- Navigation Menu Ends -->

<div class="PopWrapper" style="background: url(images/ajax-loader.gif) white no-repeat 50% 50%;height:100%;width:100%;position:absolute; z-index:6000;"></div>
<div class="wrapper">
                    <div class="grid_1">
                        <div class="grid">
                            <div class="logopng">
                                <a target="_blank" href="http://www.scriplogix.com/"><img src="images/scriplogix_logo.png" alt="0" border="0" /></a>
                            </div>
                            <div class="h_title"><?php echo ($_REQUEST['prod'] == 1)?"Custom Market Research":"Customer Insights";?></div>
                            <div class="logo_right">
                                <div class="icon_1">
                                    <div class="relative">
                                        <a class="<?php if($search_menu == "active"){?> research_inactive <?php }else{ ?>research_active<?php } ?>" href="research.php?prod=<?php echo $_REQUEST['prod'];?>"></a>
                                    </div>
                                </div>
                                <div class="icon_1 relative">
                                    <a class="<?php if($search_menu == "active"){?> search_active <?php }else{ ?>search_inactive<?php } ?>" href="#"></a>
                                </div>
                                <div class="login_img">
                                <div class="company_logo">
                                    <img src="data:image/jpeg;base64,<?php echo base64_encode( $company_row[3] ); ?>" alt="0" border="0" />
                                </div>
                                </div>
                                <div class="login_bg">
                                    <div class="logged_in_as">
                                        Logged in as
                                    </div>
                                    <div class="login_name">
                                        <?php echo $user_row->display_name;?>
                                    </div>
                                    <div class="logout">
                                        <a href="usermgmt/logout">Logout</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="grid_2">
                        <div class="grid">
                            <!-- <div class="grid_top">
                                <div class="navigation">
                                    <div class="navigation_left">
                                        <a href="#">Study name</a>
                                    </div>
                                    <!--<div class="navigation_left">
                                        <a href="#">Survery</a>
                                    </div>->
                                </div>
                                <div class="filters">

                                </div>
                            </div >-->
                            <div class="grid_left">
                                <div id="pageWrap" class="pageWrap">
                                <div class="content">
                                    <div class="pageContent">
                                        <div class="cont_wrap">
                                       <form class="ecosystem" action="ecosystem-process.php" method="post">
                                      <div class="col_l">
                        <div class="form_wrap">
                            <label>Lab Name</label>
                            <input type="text" name="lab" id="zipsearch" class="zipsearch"/>
                        </div>
                        <div class="form_wrap">
                            <label>Document Type</label>
                            <select id="sample" name="sample">
                                <option value="Image">Image</option>
                                <option value="Audio">Audio</option>
                                <option value="Video">Video</option>
                            </select>
                        </div>
                        <div action="upload.php" class="dropzone" id="my-awesome-dropzone"></div>
                        </div>
                        <div class="col_r">




                        <div class="form_wrap">
                            <label>City</label>
                            <input type="text" name="city" />
                        </div>
                        <div class="form_wrap">
                            <label>County</label>
                            <input type="text" name="county"/>
                        </div>
                        <div class="form_wrap">
                            <label>State</label>
                            <input type="text" name="state" />
                        </div>
                        <div class="form_wrap">
                            <label>Region</label>
                            <input type="text" name="region" />
                        </div>
                        <div class="form_wrap">
                            <label>Zip Code</label>
                            <input id="zipsearch" type="text" size="10" name="zip" />
                        </div>                        
                        <div class="form_wrap">
                            <label>Hash Tags</label>
                            <input id="tags_1" type="text" name="hash" />
                        </div>
                        </div>
            <input type="submit" value="submit" name="submit"/>
        </form>


                                        <div class="eco_sub_outwrap">
                                        <div class="eco_sub_wrap"><div class="filter" id="subbut">
                                    <a id="search_by" href="javascript://void();" onclick="filterValue()" >Search</a>
                                </div>
                                <div class="filter" id="resbut">
                                    <a href="javascript://void()" class="filter_reset">Reset</a>
                                </div></div>
                                </div>
                                        </div>
                                    </div>
                                </div>
                                </div>
                            </div>
                            <div class="grid_right">
                                <div class="sort_by">
                                    <div class="com_l">Tips</div>
                                    <!--<div class="sort_iconwrap">
                                    <div id="asc" class="sort_t"></div>
                                    <div id="desc" class="sort_b"></div>
                                    </div>-->
                                </div>
                                    <div class="tips_list">
                                        <!--<select name="sort_by" id="country_id" class="filter_study" id="filter_study">
                                            <option value="study_name" id="study_name">
                                                Study name
                                            </option>
                                            <option value="study_period" id="study_period">
                                                Study Period
                                            </option>
                                            <option value="study_sponsor" id="study_sponsor">
                                                Study Sponsor
                                            </option>
                                        </select>-->
                                        <ul>
                                            <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
                                            <li>Aenean commodo ligula eget dolor.</li>
                                            <li>Aenean massa.</li>
                                            <li>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</li>
                                            <li>Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.</li>
                                            <li>Nulla consequat massa quis enim.</li>
                                            <li>Donec pede justo, fringilla vel, aliquet nec, vulputate </li>
                                        </ul>
                                    </div>
                                    </div>
                        </div>
                    </div>
                    <div class="grid_3">
                        <div class="grid">
                            <div class="copy">
                                Scriplogix 2013. All Rights Reserved
                            </div>
                            <div class="copy1">
                                <a target="_blank" href="http://www.scriplogix.com/us/privacy-policy/">Privacy</a> | <a target="_blank" href="http://www.scriplogix.com/us/terms-of-service/">Terms of Use</a>
                            </div>
                        </div>
                    </div>
                </div>
<script type="application/javascript">

var study_name_fn = 'asc'; 
var study_period_fn = 'asc'; 
var study_spaonser_fn = 'asc'; 
$(document).ready(function(){

    $(".filter_study").click(function()
    {
        $(".filter_study").removeClass('selects select');   
        value = $(this).attr('id');
        if(value == 'study_name') 
        {
            sort('ul#sorting>li', 'samp.resarch_title', study_name_fn);
            study_name_fn = (study_name_fn == 'asc')?'desc':'asc';
            if(study_name_fn == 'asc')
                $(this).removeClass('selects').addClass('select');
            else
                $(this).removeClass('select').addClass('selects');
        }

        if(value == 'study_period') 
        {
            sort('ul#sorting>li', 'samp.resarch_rtitle1', study_period_fn, false);


            study_period_fn = (study_period_fn == 'asc')?'desc':'asc';
            if(study_period_fn == 'asc')
                $(this).removeClass('selects').addClass('select');
            else
                $(this).removeClass('select').addClass('selects');
            sort('ul#sorting>li', 'samp.resarch_rtitle2', study_period_fn); 
        }
        if(value == 'study_sponsor') 
        {
            sort('ul#sorting>li', 'samp.resarch_sponsor', study_spaonser_fn);
            study_spaonser_fn = (study_spaonser_fn == 'asc')?'desc':'asc';
            if(study_spaonser_fn == 'asc')
                $(this).removeClass('selects').addClass('select');
            else
                $(this).removeClass('select').addClass('selects');
        }

    });
    function sort(list, key, ordering,animate) {
            $($(list).get().reverse()).each(function(outer) {
                var sorting = this;
                if(animate != false)
                    $(sorting).animate( { height: "hide" }, 1000);
                $($(list).get().reverse()).each(function(inner) {
                    if(ordering == 'asc')
                    {
                        if($(key, this).text().localeCompare($(key, sorting).text(),'kn') > 0) {
                            if(animate != false)
                                $(sorting).insertBefore($(this)).animate( { height: "show" }, 1000);
                            else
                                $(sorting).insertBefore($(this));
                            //this.parentNode.insertBefore(sorting.parentNode.removeChild(sorting), this);
                        }
                    }
                    else
                    {
                        if($(key, this).text().localeCompare($(key, sorting).text(),'kn') < 0) {
                            if(animate != false)
                                $(sorting).insertBefore($(this)).animate( { height: "show" }, 1000);
                            else
                                $(sorting).insertBefore($(this));   
                            //$(this.parentNode.insertBefore(sorting.parentNode.removeChild(sorting), this)).slideDown();
                        }
                    }
                });
                //$(this).show();
                //$(sorting).slideUp().slideDown(500);
            });
            if(animate != false)
                $("li").animate( { height: "show" }, 1000);

        }
    $(".filter_reset").click(function()
    {
        $("#search_by").val("");
        $(".filter_study").removeClass('selects select');   
        $(".research_inactive").addClass("research_active").removeClass("research_inactive");
        $(".search_active").addClass("search_inactive").removeClass("search_active");
        sort('ul#sorting>li', 'div.serial_num', 'asc');
    });
    //filter_reset
            /*height= 0;
        $("#sorting li").each(function(is, els){

                $(this).css('top',height+'px');
                height = height+45;
            });

         $("#sorting li samp.resarch_title").sort(lxp).each(function(i, el){
            //alert('sdf');

            $("#sorting li samp.resarch_title").each(function(is, els){
                nposX = $(els).offset().left;
                nposY = $(els).offset().top;
                aa = $(els).parent().parent().html();
                if(i == is){
                    return false;
                }
                //$(this).parent().parent().css('top',a+'ps');
                //a = a+40;
            });

            $(this).parent().parent().before(aa);
            $(this).parent().parent().remove();

         });    
         function lxp(a, b){
            //alert($(b).html());
            //var adate = new Date($(a).attr("data-date"));
            //var bdate = new Date($(b).attr("data-date"));

            if(sort_fn == 'asc')
                return $(a).html().toLowerCase() > $(b).html().toLowerCase() ? -1 : 1;
            else
                return $(b).html().toLowerCase() > $(a).html().toLowerCase() ? -1 : 1;

        }

    if(sort_fn == 'asc')
        sort_fn = 'desc';
    else
        sort_fn = 'asc';
    });*/

});
function filterValue()
{
    value = $("#search_by").val();
    $('ul#sorting>li samp.resarch_title').each(function(){
         var myRegExp = new RegExp('(.*)'+value+'(.*)','i');
         if(!myRegExp.test($(this).html()))
            $(this).parent().parent().animate( { height: "hide" }, 1000);                       
    });
    $(".research_active").addClass("research_inactive").removeClass("research_active");
    $(".search_inactive").addClass("search_active").removeClass("search_inactive");
}
</script> 
</body>
</html>

这是我的main.php页面。我想使用labname自动完成详细信息。 我的suggestion_page_php如下。

<?php

if ( !isset($_REQUEST['term']) )
    exit;

$dblink = mysql_connect('localhost', 'root', '') or die( mysql_error() );
mysql_select_db('scriplogix');

$rs = mysql_query('select lab, city, state from zipcode where zip like "'. mysql_real_escape_string($_REQUEST['term']) .'%" ', $dblink);

$data = array();
if ( $rs && mysql_num_rows($rs) )
{
    while( $row = mysql_fetch_array($rs, MYSQL_ASSOC) )
    {
        $data[] = array(


            'value' => $row['lab'],
            'city'=>$row['city'],
            'state'=>$row['state'],


        );
    }
}

echo json_encode($data);
flush();

但它不起作用!我猜的方式。我做错了什么?脚本中的js有任何问题或矛盾吗?

0 个答案:

没有答案