0
아래의 PHP 코드에서 선택된 옵션을 얻고 싶습니다. 나는 왜 내가 값을 얻을 수 없는지 모르는 실수에 직면 해있다.PHP에서 선택한 옵션을 가져올 수 없습니다.
<html>
<head>
</head>
<body>
<label>Please select a make below</label> <p></p>
</body>
</html>
<?php
include("cars.php");
if (!class_exists("Cars"))
echo"<p>The Cars class is not available!</p>";
else
{
$cars = new Cars();
getList($cars);
echo $_POST["makesList"]; // I thought I could get the selected with this code but it displays the following error "Undefined index: makesList"
}
function getList($cars)
{
$makes = $cars->getMakes();
$makes=array_unique($makes);
echo '<form name="makesForm" id="makesForm" method="POST" action="showInventory.php">';
echo '<select name="makesList" id="makesList">';
foreach($makes as $make)
echo '<option value='.$make.'>'.$make.'</option>';
echo '</select>';
echo '</form>';
}
?>
다른 값으로 설정하는 방법은 있습니까? 참고로 Cars.php에 수업이 있습니다. 네가 그렇게 신경 쓰지 않을 것 같아. getList() 함수로 목록을 잘 표시합니다.
showInventory.php에 무엇이 있습니까? – ioseph
파일 상단에 오류보고 추가 'error_reporting (E_ALL); ini_set ('display_errors', 1); 개발 중에. –
양식을 제출하지 않고 어떻게 옵션을 선택할 수 있습니까? –