pucker22 Posted July 7, 2008 Share Posted July 7, 2008 Hello phpfreaks, I'm trying to code a piece of script, whereby when someone selects their location, through a drop down box, it will print out another box with a city, for example <Drop Down Box> United States United Kingdom If United States is selected then echo another drop down box. Is someone able to help me? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/ Share on other sites More sharing options...
anon_login_001 Posted July 7, 2008 Share Posted July 7, 2008 Do you desire to do this with or without the page reloading? Or does it matter? Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-583942 Share on other sites More sharing options...
revraz Posted July 7, 2008 Share Posted July 7, 2008 http://www.phpfreaks.com/forums/index.php/topic,155984.0.html Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-583944 Share on other sites More sharing options...
pucker22 Posted July 7, 2008 Author Share Posted July 7, 2008 Hi anon, Thanks for the quick reply. I would like to have the page non refresh if possible, however whichever is easiest, although I'm not looking for a redirect, such as a javascript drop-down box redirect. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-583946 Share on other sites More sharing options...
mbeals Posted July 7, 2008 Share Posted July 7, 2008 i've done it both ways. Javascript is the toughest especially if you are pulling data from a database, but AJAX does make it 'easier'. Easiest way is to just add a onchage=this.form.submit() to the first select box, have the form action call the parent page and have code that catches the selected value and populates the second box. Having done it both ways, on a fast connection, I have yet to see a difference in performance between the two methods. Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-583947 Share on other sites More sharing options...
anon_login_001 Posted July 7, 2008 Share Posted July 7, 2008 revraz supplied a pretty decent link. Take your time and go thru those instructions, and ask questions about that if you have more. If you figure it out, be sure to mark this post as Solved. Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-583949 Share on other sites More sharing options...
pucker22 Posted July 7, 2008 Author Share Posted July 7, 2008 Thanks for the responce, The tutorial seems to be pulling information from a database, rather than just having a php page whereby if you select a county, it will then echo some text, for example, <Drop Down Box> United States Then when the user selects United States it will produce this: echo ' you selected united states ' Is this possible? Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-583954 Share on other sites More sharing options...
shedokan Posted July 7, 2008 Share Posted July 7, 2008 you should try doing it in javascript, if you don't want to use a database. I'm not quite good in javascript but I think one of the fokes here might help ya. Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-584003 Share on other sites More sharing options...
revraz Posted July 8, 2008 Share Posted July 8, 2008 Well why would you want to hard code all that data? Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-584413 Share on other sites More sharing options...
DeanWhitehouse Posted July 8, 2008 Share Posted July 8, 2008 If you want help in doing it in javascript, i can help. Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-584450 Share on other sites More sharing options...
Andy-H Posted July 8, 2008 Share Posted July 8, 2008 I am not too good with this kind of stuff but I think people in the AJAX or Javascript topic will be able to help you as I think you would need to use the onChange function Quote Link to comment https://forums.phpfreaks.com/topic/113632-drop-down-box/#findComment-584478 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.