By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

JavaScript SEARCH on var

P: 15
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
Oct 29 '09 #1
Share this Question
Share on Google+
4 Replies


acoder
Expert Mod 15k+
P: 16,027
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?
Oct 30 '09 #2

P: 15
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.  
Oct 30 '09 #3

acoder
Expert Mod 15k+
P: 16,027
I would assume by passing it like you've done with "id":
Expand|Select|Wrap|Line Numbers
  1. "&s_first=" + encodeURIComponent(s_first);
Nov 1 '09 #4

P: 15
could you be more descriptive? are you being charged by the word? why even reply back if your not going to be helpful?
Nov 1 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.