Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 12-11-2009
Member
 
Join Date: Nov 2009
Posts: 583
Combo box multi selection

This is my php code, please check it out. The file name is index.php. This code includes elements of module column in my combo box. A JSP code satisfies the requirement of selecting as many options as I wish with control key hold. The porblem is that I want my select to other page and I don't have any idea how to code it. please help
Code:
<form action='show_all_res.php' method='post'>
<table border=0 align=center cellpadding="0" cellspacing="0">
<?do
{
echo "<tr><td>";
?><select multiple id="show_all_res" name="show_all_res" size="1" onClick="SetMDDsize(10)"><?
$rs = mysql_query("select * from `sage_data` GROUP BY Module");
$num = mysql_num_rows($rs);
echo "<option value='%'>All Modules</option>";
while ($row = mysql_fetch_array($rs))
{
if ($row['Module']!='')
{
echo "<option value=".$row['Module'].">".$row['Module']."</option>";
}
}
echo "</select>";
echo "</td></tr>";
}
while ($row = mysql_fetch_array($rs));?>
<tr>
<td colspan=2>
<input type='submit' value='Search by Module' name='show_all_res' id="show_all_res" onClick="alert(GetMDDselections())">
</td>
</tr>
</table>
</form>
<script type="text/javascript">
function SetMDDsize(mddSize) {
document.getElementById('show_all_res').size = mddSize;
}
function GetMDDselections() {
document.getElementById('show_all_res').size = 1; // reduce screen size
var picked = '';
for (i=0; i<document.getElementById('show_all_res').options.length; i++) {
if (document.getElementById('v').options[i].selected == true) { picked += i+','; }
}
document.getElementById('show_all_res').selectedIndex = -1; // reset list
return picked;
}
</script>
Reply With Quote
  #2  
Old 12-11-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Combo box multi selection

Hi
I read this post very carefully, I Think the solution is, give your <select> element a name that ends in square brackets.
Code:
<select name="my_name[]">
The PHP script will then receive the selected value in the array with the $_POST array $_POST['my_name'][0], $_POST['my_name'][1']. You can use other array functions to loop through and otherwise manipulate that $_POST['my_name'] array.
Reply With Quote
  #3  
Old 12-11-2009
Member
 
Join Date: Nov 2009
Posts: 583
Re: Combo box multi selection

Thank you very much
Your post has solved my question. I was trying a solution for this problem for so long now. I feel good that I have posted the question on this site. Thanks again for help solving this problem. This was a little problem, but some times it happens even small solutions are not clicked. In future I have any problem I will post again so that my problem is solve.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Combo box multi selection"
Thread Thread Starter Forum Replies Last Post
Best plan between BB Home Combo ULD 750 and BBG FN Combo 500 of BSNL TECHi India BroadBand 4 29-06-2013 11:03 AM
Which plan is good BSNL plan from BBG FN Combo 600 or BB Home Combo UL 750? SupaBoy India BroadBand 8 01-12-2011 08:58 PM
Reliance 649 combo VS Airtel 699 combo Anish-Mumbai India BroadBand 5 05-05-2010 09:45 AM
How to create multi-column combo box in vb.net? ShonaliB Software Development 2 26-02-2009 10:45 PM
Multi Speakers/multi Sound Cards PeterAGASSI Hardware Peripherals 5 12-11-2008 11:40 AM


All times are GMT +5.5. The time now is 12:40 PM.