Skip to main content

javascript - Autocomplete/sql to fill input field 2 after onblur on input1 -


okay, here goes. have 2 input fiels. first 1 works charm, autocomplete huge database name, onblur after selecting it, should automatically fill input field 2 via php script, searches selected string in database , populates input field many hits gets. how can that?

so: if first input's autocomplete finds string, it's stored (with multiple id's on same name), should id's. if there no string found in db on first input, have autocomplete written multi selecting id's manually on second box, submitting them. not important now. again, how can populate second input given string found in database first input? far have barebone:

<input type="text" size="20" onblur"" id="firstinput" name="firstinput"> <input type="text" size="40" value="" id="manualorautogroup" name="manualorautogroup"> 

php json_encodes results:

$lolz = array(); while( $row = mysql_fetch_assoc($resultset) ) { $lolz[] = array( 'value' => $row['gameid'], echo json_encode($lolz); ); } 

how client side code call , gets data filled input 2?

database sample:

gameid                         groupname

122                  stringtypedininput1foundyautocomplete

314                  stringtypedininput1foundyautocomplete

513                  stringtypedininput1foundyautocomplete

533                  stringtypedininput1foundyautocomplete

many :)

javascript - autocomplete/sql fill input field 2 after onblur on input1 - stack overflow

learn, share, build

each month, on 50 million developers come stack overflow learn, share knowledge, , build careers.

join world’s largest developer community.

sign up

okay, here goes. have 2 input fiels. first 1 works charm, autocomplete huge database name, onblur after selecting it, should automatically fill input field 2 via php script, searches selected string in database , populates input field many hits gets. how can that?

so: if first input's autocomplete finds string, it's stored (with multiple id's on same name), should id's. if there no string found in db on first input, have autocomplete written multi selecting id's manually on second box, submitting them. not important now. again, how can populate second input given string found in database first input? far have barebone:

<input type="text" size="20" onblur"" id="firstinput" name="firstinput"> <input type="text" size="40" value="" id="manualorautogroup" name="manualorautogroup"> 

php json_encodes results:

$lolz = array(); while( $row = mysql_fetch_assoc($resultset) ) { $lolz[] = array( 'value' => $row['gameid'], echo json_encode($lolz); ); } 

how client side code call , gets data filled input 2?

database sample:

gameid                         groupname

122                  stringtypedininput1foundyautocomplete

314                  stringtypedininput1foundyautocomplete

513                  stringtypedininput1foundyautocomplete

533                  stringtypedininput1foundyautocomplete

many :)

share|improve question
    
the echo needs outside of while loop. way have won't work. when receive data ajax call, you'll need to use success: function(data){ , inside you'll need set source of autocomplete 2nd input array send server. – ohgodwhy jul 7 '12 @ 0:30
    
the echo inside array. can problem. – chepe263 jul 7 '12 @ 1:45
    
normally echo outside while call yes, mistake pasting wrong position. still, because i'm muh of beginner in js, kind enough drop in few client side lines, can understand first commenter wanted me do? – flatline jul 7 '12 @ 9:56
    
ohgodwhy please, or anyone? :) – flatline jul 8 '12 @ 0:37

your answer

 
discard

posting answer, agree privacy policy , terms of service.

browse other questions tagged or ask own question.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -