Connecting Tech Pros Worldwide Forums | Help | Site Map

JavaScript SEARCH on var

Newbie
 
Join Date: Nov 2008
Posts: 12
#1: 3 Weeks Ago
i have a autosearch that is bringing in a value

Expand|Select|Wrap|Line Numbers
  1. <input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value);" onblur="fill();" />
this is my function
Expand|Select|Wrap|Line Numbers
  1. function lookup(inputString) {
  2.         if(inputString.length == 0) {
  3.     // Hide the suggestion box.
  4.     $('#suggestions').hide();
  5.  
  6.     } else {
  7. $.post("rpc.php",{queryString:""+inputString+"",one:""+$("#oneone").val()+""},function(data){
  8.  
  9.     if(data.length >0) {
  10.     $('#suggestions').show();
  11.     $('#autoSuggestionsList').html(data);
  12.     }
  13. });
  14.         }
  15.     } 
  16.  
  17.  
  18. function fill(thisValue) {
  19.         $('#inputString').val(thisValue);
  20.         setTimeout("$('#suggestions').hide();", 200);
  21.     }
  22.  
i need to now search on that value i have this
Expand|Select|Wrap|Line Numbers
  1.  <input type="button" value="Search!" onClick="inputter(document.getElementById('inputString').value)"> 
  2.  
this is my function

Expand|Select|Wrap|Line Numbers
  1.  function inputter(element)
  2.             {
  3.             parent.location='1.php?option=s_last&id=' + escape(element);
  4.  
  5.         }
  6.  
  7.  
  8.  
  9.             $(document).ready(function() {
  10.  
  11.          $('#inputString').keyup(function(e) {
  12.  
  13.         if(!e) e = window.event;
  14.  
  15.         if(e.keyCode == 13) {
  16.             inputter(document.getElementById('inputString').value);
  17.         }
  18.          }
  19.  
  20.             )
  21.         } )
  22.  
i can not get the value to 1.php can anyone tell me how i should hand this over on 1.php please

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: 3 Weeks Ago

re: JavaScript SEARCH on var


You have:
Expand|Select|Wrap|Line Numbers
  1. 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?
Newbie
 
Join Date: Nov 2008
Posts: 12
#3: 3 Weeks Ago

re: JavaScript SEARCH on var


i got this to work by getting it
Expand|Select|Wrap|Line Numbers
  1. $id = $_GET['id'];
  2. echo $id;
Expand|Select|Wrap|Line Numbers
  1.     parent.location='1.php?option=s_ladst&id=' + escape(element);
  2.  
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?

Expand|Select|Wrap|Line Numbers
  1.  $query = $db->query("SELECT $one, s_last, s_first, id FROM table_student WHERE $one LIKE '$queryString%' LIMIT 10");
  2.  
Expand|Select|Wrap|Line Numbers
  1.  
  2.  $query = $db->query("SELECT $one, s_last, s_first, id FROM table_student WHERE $one LIKE '$queryString%' LIMIT 10");
  3.  
  4.  
  5.             if($query) {
  6.  
  7.                     while ($result = $query ->fetch_object()) {
  8.  
  9.  
  10.                 //    echo '<li onClick="fill(\''.$result->s_last.'\');">'.$result->s_last.'</li>';
  11.                 echo '<li onClick="fill(\''.$result->s_last.'\',\''.$result->s_first.'\');">'.$result->s_last.', ' .$result->s_first.'</li>';
  12.  
  13.                     //echo '<li onClick="fill(\''.$result->s_last.$result->s_first.'\');">' .$result->id.'</li>';
  14.                 //echo '<li onClick="fill(\''.$result->s_last.'\',\''.$result->s_first.'\');">' .$result->s_first.'</li>';
  15.  
  16.                      }
  17.  
  18.                 } else {
  19.                     echo 'ERROR: There was a problem with the query.';
  20.                 }
  21.             } else {
  22.                 // Dont do anything.
  23.             } // There is a queryString.
  24.         } else {
  25.         //    echo 'There should be no direct access to this script!';
  26.  
  27.         }}
  28.  
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: 3 Weeks Ago

re: JavaScript SEARCH on var


I would assume by passing it like you've done with "id":
Expand|Select|Wrap|Line Numbers
  1. "&s_first=" + encodeURIComponent(s_first);
Newbie
 
Join Date: Nov 2008
Posts: 12
#5: 3 Weeks Ago

re: JavaScript SEARCH on var


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