Page 1 of 1

multiple checkboxes code works for firefox but not IE. why?

Posted: Mon Aug 28, 2006 1:06 am
by deke
is there any additional code needed to make my code work for IE and not only firefox? sorry, i'm new to php so i wouldnt know if there is any. thanks. heres the code i used...

Code: Select all

<?php
  if(isset($_POST['CheckAll']))
  {
  	if( $value == 1 )
	{	
		echo "<input type=\"hidden\" name=\"previousValue\" value=\"$value\">"; //temporary variable for future use
		if ( ( $status == "Active") or ( $status == "Inactive" ) )
		{
			$sql = "Select * from category where CatStatus = \"$status\" order by CatName"; //query searched variable from database
			echo "<input type=\"hidden\" name=\"Status\" value=\"$status\">";
		}
		else
		{
			$sql = "Select * from category order by CatName";
			echo "<input type=\"hidden\" name=\"Status\" value=\"$status\">";			
		}
		$result = mysql_query($sql, $conn) or die (mysql_error());
		
		while( $newArray = mysql_fetch_array($result))// post variables in a table for checking
		{
			$CategoryID = $newArray['CatID'];
			$CategoryName = $newArray['CatName'];
			$CategoryStatus = $newArray['CatStatus'];	 
			echo "<tr class=\"RowMouseOver\">
			<td class=\"TextTable\"><label>
			<input type=\"checkbox\" name=\"checkbox[]\" value=\"$CategoryID\". 
			  \"checked=\"checked\"/>
			</label></td>
			<td class=\"TextTableLeftAlign\">$CategoryName</td>
			<td class=\"TextTableLeftAlign\">$CategoryStatus</td>
			<td class=\"TextTableRightAlign\"><a
			href=\"categoryedit.php?CategoryName=$CategoryName&CategoryID=$CategoryID\" 
			class=\"LinkStyle1\">Edit</a></td>
			</tr>";
		}
	}
 }

?>
what could be the reason my code isnt working for IE but is doing just fine for firefox? help would be very much appreciated. thanks

Posted: Mon Aug 28, 2006 1:44 am
by mickd
What part of it isn't working in Internet Explorer? For example, what is it doing in Firefox that it is not doing in IE?

I'm assuming you're referring to the output of the script not working as intended in IE, as the PHP code itself should work the same regardless of what browser you're using.

Posted: Mon Aug 28, 2006 1:50 am
by deke
The part that isnt working for IE 6 is the part where i want to check all the checkboxes on the page. When i run the script on firefox all the checkboxes may be checked but it wont work on IE. thanks

Posted: Mon Aug 28, 2006 5:11 am
by onion2k
checked="checked" is not a valid way to make a checkbox checked. Change it to <input type="checkbox" name="chkName" value="chkValue" checked>.

I suggest you read the HTML specification .. http://www.w3.org/TR/html4/interact/forms.html#h-17.4

Posted: Mon Aug 28, 2006 5:40 am
by volka
onion2k wrote:I suggest you read the HTML specification .. http://www.w3.org/TR/html4/interact/forms.html#h-17.4
Please do so yourself ;)
http://www.w3.org/TR/html4/interact/forms.html#h-17.4 wrote:checked (checked) #IMPLIED -- for radio buttons and check boxes --
it allows the optional value checked.

And let http://validator.w3.org check <input type"=checkbox" checked /> if the doctype is xhtml.
This page is not Valid XHTML 1.0 Strict!
[...]
common cause for this error message is the use of "Attribute Minimization" in document types where it is not allowed, in XHTML for instance.
How to fix: For attributes such as compact, checked or selected, do not write e.g <option selected ... but rather <option selected="selected" ...

Thanks!!!

Posted: Mon Aug 28, 2006 6:02 am
by deke
many thanks for the help! got it working now. have a nice day and God bless. thanks again

Posted: Mon Aug 28, 2006 6:03 am
by Benjamin
Glad I could help!