JavaScript SEARCH on var

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bytesFTW99
    New Member
    • Nov 2008
    • 15

    JavaScript SEARCH on var

    i have a autosearch that is bringing in a value

    Code:
    <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
    this is my function
    Code:
    function lookup(inputString) {
    		if(inputString.length == 0) {
    	// Hide the suggestion box.
    	$('#suggestions').hide();
    	
    	} else {
    $.post("rpc.php",{queryString:""+inputString+"",one:""+$("#oneone").val()+""},function(data){
    																																				
    	if(data.length >0) {
    	$('#suggestions').show();
    	$('#autoSuggestionsList').html(data);
    	}
    });
    		}
    	} 
    
    
    function fill(thisValue) {
    		$('#inputString').val(thisValue);
    		setTimeout("$('#suggestions').hide();", 200);
    	}
    i need to now search on that value i have this
    Code:
     <input type="button" value="Search!" onClick="inputter(document.getElementById('inputString').value)">
    this is my function

    Code:
     function inputter(element)
                {
                parent.location='1.php?option=s_last&id=' + escape(element);
            
            }
    
     
    	
    	        $(document).ready(function() {
                
             $('#inputString').keyup(function(e) {
           
            if(!e) e = window.event;
     
            if(e.keyCode == 13) {
                inputter(document.getElementById('inputString').value);
            }
             }
             
                )
            } )
    i can not get the value to 1.php can anyone tell me how i should hand this over on 1.php please
    Last edited by Dormilich; Oct 29 '09, 09:21 PM. Reason: JavaScript is not Java
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You have:
    Code:
    parent.location='1.php?option=s_last&id=' + escape(element);
    Where is this called from, i.e. what is parent? Do you want to make an Ajax request or actually change the location of the (parent) page? What parameters does 1.php expect?

    Comment

    • bytesFTW99
      New Member
      • Nov 2008
      • 15

      #3
      i got this to work by getting it
      Code:
      $id = $_GET['id'];
      echo $id;
      Code:
          parent.location='1.php?option=s_ladst&id=' + escape(element);
      it give me the value of s_last however is there a way to be able to get the value of s_first as welll?

      Code:
       $query = $db->query("SELECT $one, s_last, s_first, id FROM table_student WHERE $one LIKE '$queryString%' LIMIT 10");
      Code:
       $query = $db->query("SELECT $one, s_last, s_first, id FROM table_student WHERE $one LIKE '$queryString%' LIMIT 10");
      
      			   
      			if($query) {
      				
      					while ($result = $query ->fetch_object()) {
      			
      						
      				//	echo '<li onClick="fill(\''.$result->s_last.'\');">'.$result->s_last.'</li>';
      				echo '<li onClick="fill(\''.$result->s_last.'\',\''.$result->s_first.'\');">'.$result->s_last.', ' .$result->s_first.'</li>';
      		
      					//echo '<li onClick="fill(\''.$result->s_last.$result->s_first.'\');">' .$result->id.'</li>';
      				//echo '<li onClick="fill(\''.$result->s_last.'\',\''.$result->s_first.'\');">' .$result->s_first.'</li>';
      	         
      	         		}
      					
      				} else {
      					echo 'ERROR: There was a problem with the query.';
      				}
      			} else {
      				// Dont do anything.
      			} // There is a queryString.
      		} else {
      		//	echo 'There should be no direct access to this script!';
      
      		}}

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        I would assume by passing it like you've done with "id":
        Code:
        "&s_first=" + encodeURIComponent(s_first);

        Comment

        • bytesFTW99
          New Member
          • Nov 2008
          • 15

          #5
          could you be more descriptive? are you being charged by the word? why even reply back if your not going to be helpful?

          Comment

          Working...