Jump to content

[SOLVED] Help With Displaying Multiple Checkboxes


limitphp

Recommended Posts

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

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>";
}

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....

 

 

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.