By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,303 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,303 IT Pros & Developers. It's quick & easy.

get Mutiple check box value

P: 45
hi,

i using mutiple check box but i didn't get all value...


Expand|Select|Wrap|Line Numbers
  1. as
  2.  
  3. $res=mysql_query("select * from cie where des='Resource Pipeline Associate' order by name");
  4. $j=0;
  5.         $norow=mysql_num_rows($res);
  6.         $flag=false;
  7.     while($td=mysql_fetch_array($res))
  8.     {
  9.                 for($i=0;$i<count($can);$i++)
  10.  
  11.             {    
  12.                     if("$td[1]"=="$can[$i]")
  13.                     {
  14.                         $flag=true;
  15.                         $i=count($can);
  16.                     }
  17.                     else
  18.                     {
  19.                     $flag=false;
  20.                     }
  21.             }
  22.                 if($flag==true)
  23.                 {
  24. print"        <tr><td><input type=\"checkbox\" name=\"selcie\" id=\"selcie\" value=\"$td[1]\" checked>$td[1]</td></tr>";
  25.                 }
  26.                 else
  27.                 {
  28. print"        <tr><td><input type=\"checkbox\" name=\"selcie\" id=\"selcie\" value=\"$td[1]\" >$td[1]</td></tr>";                
  29.                 }
  30.                 $j++;
  31.     }             
  32.  
  33. $cie=$_SESSION["user"];
  34. $da=$_POST['selcie'];
  35. $reqid=$_SESSION['insertid'];
  36. $res=mysql_query("insert into allocate (name,reqid) values('$da','$reqid')");
  37.  
i have problem to get mutiple value instead of i get last value from check box only....
Feb 26 '08 #1
Share this Question
Share on Google+
7 Replies


hsriat
Expert 100+
P: 1,654
Instead of name=\"selcie\", use name=\"selcie[ ]\" (line # 24, 28)

The value will be received as $_POST['selcie'][0] and so on...
Feb 26 '08 #2

P: 45
Instead of name=\"selcie\", use name=\"selcie[ ]\" (line # 24, 28)

The value will be received as $_POST['selcie'][0] and so on...

if i give selcie[] means i have validation problem in java script.....
Feb 26 '08 #3

hsriat
Expert 100+
P: 1,654
if i give selcie[] means i have validation problem in java script.....
Ok, for JavaScript, as I already showed that example (In JavaScript Forum),
use id along with name, like...

[html]<select name="selcie[]" id="selice">[/html]

and in JavaScript, instead of document.formName.selcie
use document.getElementById('selice')
Feb 26 '08 #4

Markus
Expert 5K+
P: 6,050
Use class="selcie"

If you dont. the guys in html will throw a fit.

id = unique id
when used twice it isnt unique ;)
Feb 26 '08 #5

P: 45
Ok, for JavaScript, as I already showed that example (In JavaScript Forum),
use id along with name, like...

[html]<select name="selcie[]" id="selice">[/html]

and in JavaScript, instead of document.formName.selcie
use document.getElementById('selice')

it will work in first check box only.....
Feb 26 '08 #6

Markus
Expert 5K+
P: 6,050
it will work in first check box only.....
Because id's are for unique elements.
Feb 26 '08 #7

hsriat
Expert 100+
P: 1,654
Because id's are for unique elements.
OOPS!..
I thought it was select, but it was checkbox.

@shanmugamit
look at your same question in the JavaScript forum
Feb 26 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.