get Mutiple check box value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanmugamit
    New Member
    • Feb 2008
    • 45

    get Mutiple check box value

    hi,

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


    Code:
    as
    
    $res=mysql_query("select * from cie where des='Resource Pipeline Associate' order by name");
    $j=0;
    		$norow=mysql_num_rows($res);
    		$flag=false;
    	while($td=mysql_fetch_array($res))
    	{
    				for($i=0;$i<count($can);$i++)
    
    	        {	
    					if("$td[1]"=="$can[$i]")
    					{
    						$flag=true;
    						$i=count($can);
    					}
    					else
    					{
    					$flag=false;
    					}
    			}
    				if($flag==true)
    				{
    print"		<tr><td><input type=\"checkbox\" name=\"selcie\" id=\"selcie\" value=\"$td[1]\" checked>$td[1]</td></tr>";
    				}
    				else
    				{
    print"		<tr><td><input type=\"checkbox\" name=\"selcie\" id=\"selcie\" value=\"$td[1]\" >$td[1]</td></tr>";				
    				}
    				$j++;
    	}			 
    	
    $cie=$_SESSION["user"];
    $da=$_POST['selcie'];
    $reqid=$_SESSION['insertid'];
    $res=mysql_query("insert into allocate (name,reqid) values('$da','$reqid')");
    i have problem to get mutiple value instead of i get last value from check box only....
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

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

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

    Comment

    • shanmugamit
      New Member
      • Feb 2008
      • 45

      #3
      Originally posted by hsriat
      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.....

      Comment

      • hsriat
        Recognized Expert Top Contributor
        • Jan 2008
        • 1653

        #4
        Originally posted by shanmugamit
        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.formNa me.selcie
        use document.getEle mentById('selic e')

        Comment

        • Markus
          Recognized Expert Expert
          • Jun 2007
          • 6092

          #5
          Use class="selcie"

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

          id = unique id
          when used twice it isnt unique ;)

          Comment

          • shanmugamit
            New Member
            • Feb 2008
            • 45

            #6
            Originally posted by hsriat
            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.formNa me.selcie
            use document.getEle mentById('selic e')

            it will work in first check box only.....

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Originally posted by shanmugamit
              it will work in first check box only.....
              Because id's are for unique elements.

              Comment

              • hsriat
                Recognized Expert Top Contributor
                • Jan 2008
                • 1653

                #8
                Originally posted by markusn00b
                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

                Comment

                Working...