![]() |
| ||
| Populating a Drop-down List hi i have the following issue. i'd much appreciate someone helping me out here. i'm trying to let a drop-down list (which will be placed, and vary on many pages) with the contents of an array. how can i get that done? plus, once a certain element has been selected, i'd like that a link appears that links to a specific (filename with certain naming, according to the selected element) file. how could that be implmented? again, i'd much apprecite your help pygmalion |
| ||
| Re: Populating a Drop-down List Below is a basic example of how I wrote an array drop down for a choice of messengers. $msgr is simply a post result for msgr, so it retains what you selected. <fieldset><label for="msgr">Primary Messenger:</label> As for the other thing your on about, perhaps you want to write some javascript thats populated then just shows the data. Alternatively you could use AJAX or simply reload the page based on the selection. Perhaps you can explain what your after more in depth. |
| ||
| Re: Populating a Drop-down List Another solution would be, instead of using a foreach() you could use a for() loop. $arr = array("cat", "dog", "horse", "frog"); Enjoy. |
| ||
| Re: Populating a Drop-down List thanks a lot for your elaborate replies. the populating of the drop-down list now works fine. the case is as follows, i'm trying to populate the dropdown-list via a multidimensional array (because they will be audio recordings of parts of each chapter of a book). now, first i'd like to declare the multi-dimensional array, which i have done as follows. $book1 = array("chapter1" => array(),now, i'd like to populate the second dimension of this array by using for-loops, as follows:$chapter1_amount = 4;i think herein lies the mistake, at declaring the variables at the 2nd dimension. am i doing this correctly? afterwards, i show the drop-down list as you guys have suggested: echo "<select name=\"book1\"><option value=\"bleh\">Choose Part</option>";when doing it this way, i get a drop-down list which just has three identical elements, all entitled 'Array'. once this is done, i was just wondering how i could for example manipulate a link next to it to link to a file according to the chosen element in the list. i'd very much appreciate your help, really pygmalion |
| ||
| Re: Populating a Drop-down List hi again. i'd much appreciate anyone's help. this is quite of an importance to me. thanks in advance pygmalion |
| ||
| Re: Populating a Drop-down List /* init */This theoretically works. It's 3am and i didnt compile it, but looks fine to me. For manipulating the link acording to the dropdown list. You'd need to call a javascript function to generate the link. When you choose an option in the list, you'd call the javascript function to update the link. /* HTML */ |
| ||
| Re: Populating a Drop-down List i did everything as you said, and it worked neatly. thanks so much, really pygmalion |
| ||
| Re: Populating a Drop-down List Not a problem. |
| All times are GMT -4. The time now is 3:38 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC