1,105,208 Community Members

checkbox

Member Avatar
sallycheng
Newbie Poster
11 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

It cannot display the value of the checkbox,please tell me what wrong of it!
Thak you

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" c />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_POST["Sumbit"]))
{
$fruit=isset($_POST["apple"]) ? $_POST["apple"]:"";
if(isset($_POST["bananan"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["bananan"];
}
if(isset($_POST["orange"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["orange"]; 
} 
print"your faviours fruit is:".$fruit;
}
?>
<form id="form1" name="form1" method="post" action="fruit.php">
  <label>
  <input name="apple" type="checkbox" id="apple" value="apple" />
  </label> 
  apple
  <label>
  <input name="bananan" type="checkbox" id="bananan" value="bananan" />
  banana
  <input name="orange" type="checkbox" id="orange" value="orange" />
  </label>
orange         
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
</form>
</body>
</html>
Member Avatar
BzzBee
Posting Whiz
327 posts since Apr 2009
Reputation Points: 5 [?]
Q&As Helped to Solve: 48 [?]
Skill Endorsements: 0 [?]
 
0
 

try following php code

<?php
if($_POST)
{
	$fruit=isset($_POST["apple"]) ? $_POST["apple"]:"";
	
	if(isset($_POST["bananan"]))
	{
		if(!empty($fruit))
		{
		$fruit.=", ";
		$fruit.=$_POST["bananan"];
		}
	}
	if(isset($_POST["orange"]))
	{
		if(!empty($fruit))
		{
		$fruit.=", ";
		$fruit.=$_POST["orange"]; 
		}
	} 
print"your faviours fruit is:".$fruit;
}
?>
Member Avatar
sourcebits
Junior Poster
102 posts since Dec 2008
Reputation Points: 6 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
 
1
 

It cannot display the value of the checkbox,please tell me what wrong of it!
Thak you

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" c />
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_POST["Sumbit"]))
{
$fruit=isset($_POST["apple"]) ? $_POST["apple"]:"";
if(isset($_POST["bananan"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["bananan"];
}
if(isset($_POST["orange"]))
{
if(!empty($fruit))
$fruit.=", ";
$fruit.=$_POST["orange"]; 
} 
print"your faviours fruit is:".$fruit;
}
?>
<form id="form1" name="form1" method="post" action="fruit.php">
  <label>
  <input name="apple" type="checkbox" id="apple" value="apple" />
  </label> 
  apple
  <label>
  <input name="bananan" type="checkbox" id="bananan" value="bananan" />
  banana
  <input name="orange" type="checkbox" id="orange" value="orange" />
  </label>
orange         
<label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label>
</form>
</body>
</html>

Pl replace this line, Submit mis-spelled
if(isset($_POST["Submit"]))

Question Answered as of 4 Years Ago by sourcebits and BzzBee
Member Avatar
sallycheng
Newbie Poster
11 posts since Mar 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Pl replace this line, Submit mis-spelled
if(isset($_POST["Submit"]))

Thank you very much!My problem had solved!

Member Avatar
sourcebits
Junior Poster
102 posts since Dec 2008
Reputation Points: 6 [?]
Q&As Helped to Solve: 14 [?]
Skill Endorsements: 0 [?]
 
0
 

Thank you very much!My problem had solved!

Great!!

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article