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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deke
Forum Newbie
Posts: 5
Joined: Wed Aug 23, 2006 12:59 am

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

Post 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
Last edited by deke on Mon Aug 28, 2006 1:45 am, edited 1 time in total.
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post 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.
deke
Forum Newbie
Posts: 5
Joined: Wed Aug 23, 2006 12:59 am

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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" ...
deke
Forum Newbie
Posts: 5
Joined: Wed Aug 23, 2006 12:59 am

Thanks!!!

Post by deke »

many thanks for the help! got it working now. have a nice day and God bless. thanks again
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Glad I could help!
Post Reply