Re: how to use HTML_AJAX for dynamic drop menu creation
| From: | Joshua Eichorn | Date: | Fri, 21 Apr 2006 16:27:58 +0000 |
| Subject: | Re: how to use HTML_AJAX for dynamic drop menu creation | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23800@lists.php.net to get a copy of this message | ||
Octavi Fors wrote:
Hi, I made some progress on the questions I posted in my last message. In particular: -I found the source code of MenuExample in the HTML_AJAX_Presentation.zip file posted in the same webpage. Sorry for not reading carefully before asking :-) -I was able to workaround the sub PHP5 version problem by following the recommendation: $server->registerClass(new MenuExample(),'menuexample',array('getStates','getCities')); posted in example2.php of http://www.azphp.org/files/HTML_AJAX.html So I reproduce the MenuExample result inside my application. Glad you got it working
However, I would like HTML_AJAX to be able to do something else from what is offered in MenuExample. In particular, I would like to make disapear the Cities menu when a given value of States menu is selected and make appear an input text box instead (where the user could type the City name). Therefore, the Cities menu and text box should not appear simultaneously: once one of them depending the selected value in state menu. Can this be done with HTML_AJAX? How? Well this is really just pure JavaScript at this point.<select id="Cities"></select> <input id="CitiesBox" style="display:none"> var callbacks = { getStates: function(result) { _fillInMenu("States", result); }, getCities: function(result) { if (result == false) { document.getElementById('Cities').style.display = 'none'; document.getElementById('CitiesBox').style.display = 'inline'; } else { document.getElementById('Cities').style.display = 'inline'; document.getElementById('CitiesBox').style.display = 'none'; _fillInMenu("Cities", result); } } } Updating the callback to something like that should do it. -josh
Thanks in advance, ****************************************************** Octavi Fors Universitat de Barcelona. ?rea de Tecnologies. Aplicacions. mailto:ofors@ub.edu ******************************************************* On Fri, 21 Apr 2006, Octavi Fors wrote:Dear Josh, thanks for helping and giving the general scheme you suggest. The MenuExample demo posted at http://htmlajax.org/materials/HTML_AJAX_Presentation/MenuExample/ seems to be exactly what I want. However, I don't see the source code (both html/js and php) available either in the same website or in the local PEAR/HTML/AJAX directory. Does anybody know where I can get the code of this example? BTW, I'm running PHP 4.3.10. Is the note posted in the url above: "Note that the demo's won't work on php4 unless you update the controller.php in each to register method names with the correct case." a concern for that Menu example? How should I adapt it to make it work? Thanks in advance, ****************************************************** Octavi Fors Universitat de Barcelona. ?rea de Tecnologies. Aplicacions. mailto:ofors@ub.edu ******************************************************* On Tue, 18 Apr 2006, Joshua Eichorn wrote:Octavi Fors wrote:Hi, I am in the need of dynamically generate a drop menu (drop2) whose elements are function of the option value selected in another drop menu (drop1). Both menus are feeded via PEAR:DB database connection. HTML_AJAX seemes to be a good choice for that. However, I'm totally newbie in AJAX and after reading for some examples and documentation I am still stuck and cannot realize what my application should look like. I would be very grateful if somebody can bring me some light in this and make me start in this promising world of AJAX :-) Thanks in advance, ****************************************************** Octavi Fors Universitat de Barcelona. ?rea de Tecnologies. Aplicacions. mailto:ofors@ub.edu *******************************************************Your basic app structure would be: Page that generates the original html/javascript ajax.php (contains an instance of HTML_AJAX_Server and registers a class for giving the values of the second menu) when drop1 is selected is uses the remote stub of the option generation class to make an ajax call passing in the selected option the callback for the remote method updates drop2 I can give you more details if needed -josh