PDA

View Full Version : help..how to create search field



rex0098
18 Dec 2009, 10:30 AM
hello every one..is it posible to incorporate a search field in a form..such that when i input a name and hit the search button it will search the database for information related to it and the send it back to specififc fields on the form...i'm not using grids just individual textfields....

i tried to do it but i cant get it to work because when i use getForm.load({url:'getdata.php'}) it returns blank values bacause the value of my search field was not submitted to getdata.php and when i use getForm.submit({url:'getdata.php'}) the value of my search field is submitted but the data i got from getdata.php is not seen in my form because it's not loaded....

what should i do? please tell me....

thanks....

tubamanu
19 Dec 2009, 6:03 AM
there are several ways to create an ajax search. last time i used this:
Adding to an ExtJs Button a handler, which makes an ajax call. After the ajax call u have to wait for serverresponse and add the response from your sever to your textfield. it can be done like this snippet.
I used as serverresponse data in jsonformat.



Ext.Ajax.request({
url : getData.php,
success: function(objServerResponse){
serverData = Ext.util.JSON.decode(objServerResponse.responseText);
yourTextfield.setValue(serverData);
}
});

Condor
19 Dec 2009, 6:07 AM
So you want:

formPanel.getForm.load({
url:'getdata.php',
params: {
mySearchParam: mySearchField.getValue()
}
});

rex0098
20 Dec 2009, 5:39 PM
condor,
here is what i did but i don't really know how it works...what does "mySearchParam" stands for?? and when i run the code an error that says my Search_PT is not defined appears...


var form_buttons_search = {

text: 'Search',
handler: function () {
REDEEM_Form.getForm.load({
url:'get_RR_data.php',
params: {mySearchParam: Search_PT.getValue()
}
});
}
}
pleas i need your response.......thank you...

rex0098
20 Dec 2009, 7:37 PM
condor,
i experimented a little an its working now..thanks much....