kusal Posted March 28, 2008 Share Posted March 28, 2008 Hello I have a category select menu, what I want is to when user select a category I have to repopulate the sub category select menu with items can I do this with out AJAX, it does not matter if there is a another request can I use a onchange to call another php function? Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/ Share on other sites More sharing options...
Cep Posted March 28, 2008 Share Posted March 28, 2008 If you are using Javascript events your going to need to use an AJAX method. Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-502925 Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 You can do this without using AJAX ;) ;) There are two ways 1. Using form reload In this method on change of the combobox will have to reload using the combobox value and fill the sub combo > Not so good method 2. Using javascript When you load the page you have to store all the subcategories in a javascript two dimensional array and on change of the main combobox you have to fill the sub combobox values by filtering the array of sub categories one doubt ??? ??? :o :o if you can allow the request you cannt you use ajax ??? ??? ??? Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-502935 Share on other sites More sharing options...
Cep Posted March 28, 2008 Share Posted March 28, 2008 How would Javascript know what the new items were unless you planned to type them all into your Javascript file/tags? It would more likely come from a database source, which will require a request to the server, which will be an AJAX method. Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-502938 Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 i dont say you have to hard code the sub category fields on loading the page you have to take it from sub category table and will have to dynamically create a javascritp array : : Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-502943 Share on other sites More sharing options...
kusal Posted March 28, 2008 Author Share Posted March 28, 2008 Thanks for the help, I found a solution Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-502954 Share on other sites More sharing options...
Cep Posted March 28, 2008 Share Posted March 28, 2008 i dont say you have to hard code the sub category fields on loading the page you have to take it from sub category table and will have to dynamically create a javascritp array : : And what happens when the data in sub category table changes? This will not update the users array and therefore would cause problems. AJAX is the only way to do this properly. Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-503008 Share on other sites More sharing options...
atl_andy Posted March 28, 2008 Share Posted March 28, 2008 Can you provide a link or direction about the option you found? I'm trying to get the same thing working, but my option uses AJAX and I would rather not reload the page. Link to comment https://forums.phpfreaks.com/topic/98285-poulate-a-option-field-on-change/#findComment-503102 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.