timsmith Posted December 8, 2008 Share Posted December 8, 2008 Hi, I have a php file, which contains an array which holds a list of drinks that are held in a text file (code shown below) <?php $cocktails = file ("ctaillist.txt", "r"); // This is opening a text file called ctaillist.txt and reading it into the array echo "<select>"; foreach($cocktails as $cocktail) //everytime $cocktail is outputted it will display the next cocktail in the array { echo "<option name='$cocktail'>$cocktail</option>"; } echo "</select>"; The data outputted from the array is being stored in a drop down menu, what I want to do is to be able to click on an option from the menu, then this should do an onclick, which will locate a text file and output it to the html page. How would I go about doing an onclick for this? and will this involve making a loop? Link to comment https://forums.phpfreaks.com/topic/135988-using-onclick-with-array-elements/ Share on other sites More sharing options...
gevans Posted December 8, 2008 Share Posted December 8, 2008 the onclick event will be javascript not php! Link to comment https://forums.phpfreaks.com/topic/135988-using-onclick-with-array-elements/#findComment-708913 Share on other sites More sharing options...
chronister Posted December 8, 2008 Share Posted December 8, 2008 Interesting, there was a post I helped with that was *almost* exactly like this a few days ago..... See this post.. it is an ajax drink listing. You will have to edit to make it look up the text file and such, but same concept. http://www.phpfreaks.com/forums/index.php/topic,228222.0.html Nate Link to comment https://forums.phpfreaks.com/topic/135988-using-onclick-with-array-elements/#findComment-708961 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.