hi all, i want to get data of an text box to be filled in an .change event of a select box. but that data should be retrieved from db. i dont want to call ajax since it will take time to hit every time the select box changed, So i have an idea to store the data as an array in hidden field and pass it to the jquery.. Is there any way to da this? Can any body tell me how to store array in hidden input field? Thanks in advance...
Can you load the data at page load ? If you can, then use Json. make a variable and fill it with json data from php at page load then use jquery json functions to process it and search trough the arrays. You can also use the data function from jquery! If you need help with it post back I will try to help you.
make a variable in your page header with the data you want to search in json format. backend code $your_data = json_encode($your_data); ?> <script language="JavaScript"> var mydata = <?php echo $your_data;?>; </script> <?php Code (markup): frontend code <script language="JavaScript"> var mydata = json_string_here; </script> Code (markup): And you will process the data after with the help of jquery json functions http://php.net/manual/en/book.json.php Code (markup): http://api.jquery.com/jQuery.parseJSON/ Code (markup):
Sorry,Still i cant get you back end code should be just a php code there where comes js? and what is json used for here?
I suggested json because it was easier to communicate between js and php. Do you have a page where you tried this ?