Results 1 to 2 of 2

Thread: Problem in Search

  1. #1
    Join Date
    Sep 2010
    Posts
    188

    Problem in Search

    Hi

    Before, I got a problem in using arrow up and down key in choosing employee name.. And now with the help of other I fixed it, but now I got an problem when I search the name of employee his data was not displayed. And also when i type in search field after I type one letter it focus/fall in the name list..it wrong..it would be the cursor will stick in the textfield while I'm typing letters.

    Here is my new code:
    left.tpl
    Code:
    <script>
    window.onload = function() {
      var ul = document.getElementById('searchpayroll');
      var links = ul.getElementsByTagName('a');
      var i = 0;
     
      document.onkeyup = function(e){
        e = window.event || e;
        var key = e.charCode || e.keyCode;
        //if (key == 38) {
          if (key == 40) { 
          // up pressed
          //if (i < links.length - 1) i++;
          if (i < links.length - 1) i++; 
        }
        else if (key == 38) {
          // down pressed
          if (i > 0) i--;
         // if (i < 0) i++; 
        }
        // focus on link
        links[i].focus();
        // request content in here for link with ajax
       // alert(links[i].href);
      }
    }
    </script>
    <div id="Search">
    <form>
    <p class="serif"><b>Search Lastname:</b></p>
    <input type="text" name="search_" size="20" onkeyup="searchemppay(this.value);">  
    <!--<div id="searchpayroll" style="overflow:auto; height:390px; width:auto; margin-left:2px" >-->
    <hr />
    <ul id="searchpayroll" style="overflow:auto; height:385px; width:auto; margin-left:2px;">
    <!--<ul>-->
    {section name=co_emp loop=$personalAll}
    <!--<li onclick="changeEmployeePay('{$personalAll[co_emp].EMP_ID}')">{$personalAll[co_emp].FULLNAME}</li> -->
    <li><a href="SearchData.php?queryEmpID={$personalAll[co_emp].EMP_ID}">{$personalAll[co_emp].FULLNAME}</a></li>
    <hr />
    {sectionelse}
    <li>No records found</li>
    {/section}
    </ul>
    </div>
    </div>
    and the javascript code:
    Code:
    <script>
    function searchemppay(queryString) {
        
        var ajaxRequest = remoteRequestObject();
        ajaxRequest.onreadystatechange = function() {
            if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
                var result = ajaxRequest.responseText;
                document.getElementById('searchpayroll').innerHTML = result;
            } 
        }
        var url = "search.php?query=" + queryString; 
        ajaxRequest.open("GET", url, true);
        ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        ajaxRequest.send(null);
    
    }
    
    function changeEmployeePay(queryID) {
    
    window.location = "SearchData.php?queryEmpID=" + queryID;
    }
    </script>
    search.php //where i encountered problem
    Code:
    <?php
    
    session_start();
    include 'config.php';
    
    $queryString = $_GET["query"];
    
    $queryStr = trim($_GET["queryEmpID"]);
    
    $_SESSION['empID'] = $queryStr; 
    
    if ($queryString == "" || $queryString == null) {
    
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL 
            ORDER BY FULLNAME ASC";
    }
    else {
    $sql = "SELECT EMP_ID, CONCAT(LNAME, ', ',  FNAME, ' ', MI, '.') AS FULLNAME FROM PERSONAL WHERE LNAME LIKE '" . $queryString . "%' ORDER BY FULLNAME ASC";
    
    }
    
    $recPersonalQuery = $conn->Execute($sql);
    if (!$recPersonalQuery->BOF) {
        $recPersonalQuery->MoveFirst();
    }
    
    echo "<hr />";
    echo "<ul>";
    while (!$recPersonalQuery->EOF) {
        $empID   = $recPersonalQuery->fields["EMP_ID"]; 
        $empFullName = $recPersonalQuery->fields["FULLNAME"];
        echo "<a href='SearchData.php?queryEmpID=('$empID')'; style= 'font-family:'Times New Roman',Times,serif; font-size:10%;'>$empFullName</li>";
        echo "<hr />";
        $recPersonalQuery->MoveNext();
    } 
    echo "</ul>";
    
    $recPersonalQuery->Close();
    exit();    
    
    ?>
    and the SearchData.php
    Code:
    <?php
    session_start();
    
    $queryStr = trim($_GET["queryEmpID"]);
    
    $_SESSION['empID'] = $queryStr; 
    
    session_write_close();
    header("Location:DisplayEmpPayroll.php");
    exit();
    ?>
    I hope someone can help me to resolved this another issue..

    But I tried also to fix it..

    Thank you so much..

  2. #2
    Join Date
    Jan 2012
    Posts
    2
    I need a web programmer/designer to create a dynamic website for a start up business.

    The website is 20 pages, mostly text and pictures.

    Primarily, I'm looking for a candidate with a creative artistic mind.

    He/She needs also to be familiar with Linux servers, e-commerce applications, and social media.

    The developer should be located in Sacramento area.

    Pay: 13 per hour

Similar Threads

  1. problem with search form
    By trevanhetzel in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 0
    Last Post: 05 Jan 2011, 06:10 PM
  2. Problem With Google Search Engine
    By icu222much in forum Search Engine Optimization and Marketing
    Replies: 0
    Last Post: 14 Aug 2008, 04:43 PM
  3. Custom search engine - search google and my site
    By lance71 in forum Search Engine Optimization and Marketing
    Replies: 1
    Last Post: 27 Jun 2008, 11:09 AM
  4. Product Search Script? (like in Walmart product search, not like Google site search)
    By pap74 in forum Client & Server Side Scripting (PHP, ASP, JavaScript)
    Replies: 1
    Last Post: 23 Feb 2008, 11:03 PM
  5. Page and Search Rank Problem
    By akimardb in forum Search Engine Optimization and Marketing
    Replies: 1
    Last Post: 11 Apr 2007, 09:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •