limitphp Posted April 15, 2009 Share Posted April 15, 2009 I have a page where I add artists' songs to my website. Its an admin page for just me. There will be a box that says how many songs do I want to add. After I put in the number and hit a go button.....the page will add: a textbox for the song name. a drop down select with a list of all the genres to select the genre for that particular song. it will add these two items for as many songs as I put in the number for. My question is this..... the genre drop down list will use php to fill it. It will be a simple query that gets all the genres from the genre table and displays them in the select drop down list. I will need to fill the select drop down once with php, but is it possible to repeat this drop down list like I want to do? thanks Link to comment https://forums.phpfreaks.com/topic/154206-solved-help-with-displaying-multiple-checkboxes/ Share on other sites More sharing options...
Zhadus Posted April 15, 2009 Share Posted April 15, 2009 Very possible to do, although the title talks about checkboxes? Here is an example: <?php $amt = $_GET['songAmount']; $genres = array('Rock', 'Rap', 'Country'); for ($x = 0; $x < $amt; $x++) { echo "<select name='genre[$x]'>"; for ($y = 0; $y < sizeof($genres); $y++) echo "<option value='$genres[$y]'>$genres[$y]</option>"; echo "</select>"; } Link to comment https://forums.phpfreaks.com/topic/154206-solved-help-with-displaying-multiple-checkboxes/#findComment-810687 Share on other sites More sharing options...
limitphp Posted April 15, 2009 Author Share Posted April 15, 2009 Very possible to do, although the title talks about checkboxes? Here is an example: <?php $amt = $_GET['songAmount']; $genres = array('Rock', 'Rap', 'Country'); for ($x = 0; $x < $amt; $x++) { echo "<select name='genre[$x]'>"; for ($y = 0; $y < sizeof($genres); $y++) echo "<option value='$genres[$y]'>$genres[$y]</option>"; echo "</select>"; } Sorry about that...I meant drop down select lists..... When I click the go button to submit how many songs I need it will call a javascript function that will inject these lists in the html page via a innerHTML call.... sort of like this: var num = document.frm.members.value; var value1=''; for (var i=1; i<=num; i++) { //select drop down here } document.getElementById('membersBox').innerHTML = value1; Actually...I think I know how I'll do it.... Link to comment https://forums.phpfreaks.com/topic/154206-solved-help-with-displaying-multiple-checkboxes/#findComment-810725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.