• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

php and chrome

Would anyone know why the following code works fine in IE8 and Firefox but not in google chrome:

<!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" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<p><strong>Array 1:</strong><br />
  <br />
  <?php
$months=array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
for($iCnt = 1 ; $iCnt <= 12 ; $iCnt++){      echo '<option value="'.sprintf('%02d',$iCnt).'">'.$months[$iCnt - 1].'</option><br />';}
?>
    <strong><br />
    Array 2:</strong><br />
  <br />
  <?php
$arr = array("jan", "feb", "mar","april","may");
foreach($arr as $key=>$value){echo '<option value="'.str_pad((int)($key+1), 2, '0', STR_PAD_LEFT).'">&nbsp;'.$value.'</option>';}
?>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>
0
doctorbill
Asked:
doctorbill
1 Solution
 
haloexpertsexchangeCommented:
its because you are missing the select for the options and so since chrome is stricter it is not showing anything in chrome.
<!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" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<p><strong>Array 1:</strong><br />
  <br />
  <select name ="capsMonths"><--add this
  <?php
$months=array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
for($iCnt = 1 ; $iCnt <= 12 ; $iCnt++){      echo '<option value="'.sprintf('%02d',$iCnt).'">'.$months[$iCnt - 1].'</option><br />';}
?>
  </select>
    <strong><br />
    Array 2:</strong><br />
  <br />
  <select name="short"><--add this
  <?php
$arr = array("jan", "feb", "mar","april","may");
foreach($arr as $key=>$value){echo '<option value="'.str_pad((int)($key+1), 2, '0', STR_PAD_LEFT).'">&nbsp;'.$value.'</option>';}
?>
  </select>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

Open in new window

0
 
doctorbillAuthor Commented:
very fast
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now