What PHP libraries would you recommend to implement the following:
Three dependent drop-down lists
Three XML data sources
AJAX-based
Essentially, I'd like to create an XML database and wire up a form that allows the user to select three different dependent parameters:
User clicks Region
User clicks District (filtered by Region)
User clicks Station (filtered by District)
Even though I would like to use PHP and XML, the general problem is:
One XHTML form
Three dependent, cascading drop-down lists
Three flat files (no relational database) for the list data
The solution must be efficient, simple, reliable, and cross-browser.
What technologies would you recommend to solve the problem?
Thank you!
I'd say jQuery and the Autocomplete plugin.
make three conventional text boxes and enhance them with autocomplete()
each one requests data from the server as the user types, via AJAX GET requests
the server sends back the matching data as line-based text, which in turn the autocomplete plugin uses to display a list of options
hook up an handler for the result event of the dropdowns, storing the selected option.
the second textbox would require the first to be set and so on
each textbox requests data from the server including all previously selected options so the server can find the right data
the server works with DOMDocument and DOMXPath to get the data, the autocomplete plugin has built-in client side caching do ease load on the server
Vanilla php and a good JavaScript framework is all you'd need.
You'll need to build a php script to generate filtered lists of districts and stations based on the provided parent filter (pushing out the data as either xml or json). The php will need to parse the xml data and filter the list based on criteria (obviously a db will handle this better than manually parsing xml)
Then use a js framework to query the php files every time the parent list's value changes. A js framework isn't required (and actually cause some bloat), however it'll make developing the app an easy task.
Personally I'd recommend jQuery due to the easy learning curve, but any popular js framework will yield the same result.
Related
I'm looking for some help about "Custom View". I looked throw the internet but can't find it (maybe cause of my bad key words).
I created a custom view with a Table format. The goal is to display content (based on a content type) in a table.
I already have my content showing, I can reorganize rows by client/sector.. by clicking on the column header but now I'd like to :
Filter result depending on the string in an input textfield
and
Filter result using a dropdown menu
I guess It's client side, but I'm a beginner in drupal so it's a bit hard to find out.
Here is what I'd like :
http://hpics.li/175e64e
For the select filter, you should try using exposed filters in your view. In the filter section, add filter on the fields and expose them. If these fields are taxonomy reference fields it should work right away. Otherwise it depends : with entity reference I think Better Exposed Filters can be usefull.
With plain text fields it will be more difficult to get what you want (personnaly I give up on exposed filters when it becomes to complicated), but still possible with this approach and a bit of client side work.
The general idea is to create JSON view wich gets all differents values for a text field across the nodes, using Views Data Source (or get all nodes with fields values then fetch unique values for each fields in javascript).
On client side, on the page load make an ajax call to this view to get an array of all possible values, then build your select list using this array, and then do a client side filtering (using for example the excellent Isotope).
But in my opinion you need to take side : all with views and exposed filters (server side, can be hard and frustrating...) or all in JS (client side), mixing the two should result in a big mess...
For the plain text search box I would choose to work client side, Views won't be of any help I'm afraid.
You can also find good javascript plugins for table sorting / filtering like Datatables.
Good luck.
I want to search on website pragmatically using PHP like as we search on website manually, enter query on search box press search and result came out.
Suppose I want to search on this website by products names or model number that are stored in my csv file.
if the products number or model number match with website data then result page should be displayed ..
I search on below question but not able to implement.
Creating a 'robot' to fill form with some pages in
Autofill a form of another website and send it
Please let me know how we can do this PHP ..
Thanks
You want to create a “crawler” for websites.
There are some things to consider first:
You code will never be generic. Each site has proper structure and you can not assume any thing (Example: craigslist “encode” emails with a simple method)
You need to select an objective (Emails ? Items information ? Links ?)
PHP is by far one of the worst languages to do that.
I’ll suggest using C# and the library called AgilityHtmlPack. It allows you to parse HTML pages as XML documents (So you can do XPath expressions and more to retrieve information).
It surely can be done in PHP, but I think it will take at least 10x time in php compared to c#.
I need to create a specific <option> list on a form, depending on which option is selected by the user on the previuos <select> list. In this case, as part of a school ERP, when user selects course the system should load on the next field only the subjects related to this course.
This can be done by ajax, using the 'change' method, posting on real-time course ID, and giving back as the result of the query, the list of related subjects wich is loaded on its <select> list.
Is making this by having a separate file instead of trying another options the best practice to solve this cases? I mean, if the best way to do this is by having an specific file for every list that must be dinamically generated, then I'll make it this way, but I feel that having a php file for every single dynamic list that should be generated on real-time maybe is not the most efficient way to do this (got many form fields that should behave this way).
One PHP file will do.
Use this tutorial to learn about URL parameters:
http://html.net/tutorials/php/lesson10.php
Combine with this tutorial on how to retrieve data from a database:
http://html.net/tutorials/php/lesson20.php
The idea here is, using AJAX, instead of fetching your list like this:
http://example.com/list/thing1.php, http://example.com/list/thing2.php
You use a single PHP file, like this:
http://example.com/list.php?foo=thing1, http://example.com/list.php?foo=thing2
So instead of having a php file for every single dynamic list you can have one file that loads and format the specific data you need dynamically.
I would like to build a Layout designer in PHP or would like to use a readymade script( even if it is a paid one )
Basically I would like to create a sort of Layout where users could choose fields to add from a "field chooser". Each field could be of any type... and we would like to provide a field group too, where the user could choose the number of columns, and make the columns of this "panel" droppable.
We should drag a field from a list, and drop the field to a placeholder on a Form (Panel?).
Finally, is it possible to "read" the form layout in order to store it for later use?
thanks
kabir
Yes there is a Drag and drop form/window designer for PHP - since 2007 the Delphi PHP IDE. It is now become part of the RADPHP X2 IDE available from Embarcadero. Both use the Delphi VCL framework.
There is RADPHP from Embarcadero technologies. It uses vcl for php framework for visual design. You can drag & drop while designing the page. But the html code it produces is not compatible with w3 standards.
Drag and drop isn't available in PHP. PHP is a server-side language; what you're asking for in client-side and would be accomplished using something like JavaScript. You would then use PHP to read the user's choices based on an event occuring, i.e. an item dropped or the user click a confirmation button.
i need in an php file three drop down boxes or multiple select boxes.
the entries from these boxes are in a mysql database.
the single problem is that the entries in the thrid box depend on the second, and the entries in the second depend on the first.
can someone help? know any examples?
There are basically 3 ways to achieve this:
Use JavaScript to submit() the form to the server side during onchange of the dropdown and let PHP load the options and render the child dropdown accordingly based on the selected dropdown value. Technically the simplest way, but also the least user friendly way. You probably also want to revive all other input values of the form.
Let PHP populate all possible child dropdown values in a JavaScript array and use a JavaScript function to fill and display the child dropdown. A little bit trickier, certainly if you don't know JavaScript yet, but this is more user friendly. Only caveat is that this is bandwidth and memory inefficient when you have relatively a lot of dropdown items. Imagine three dropdowns which can each hold 100 items, that would mean a JS array of 100 * 100 * 100 = 1 million items. The page might then grow over 1MB in size.
Let JavaScript fire an asynchronous (ajaxical) HTTP request to the server side and fill and display the child dropdown accordingly. Combines the best of options 1 and 2. Efficient and user friendly. jQuery is extremely helpful in this since it removes the concerns about crossbrowser compatibility with regard to firing ajaxical requests and traversing the HTML DOM tree. You would otherwise end up with double, triple or even much more of code needed to achieve this.
If you let know in a comment or an update of your question which way you would prefer and where exactly you're stucking while implementing the solution, then I'll maybe update the answer to include a basic kickoff example.
I'm from Portugal, so, what we do it's based on Portuguese language, never the less, we've made many working websites and platform's with what you want, please check this link...
if this is what you want, I can send you the code:
http://www.medipedia.pt/home/home.php?module=farmacia