Jump to content

using onclick with array elements


timsmith

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.