Reputation: 139872
<?php
$salaries = array(1000,1500,2000,2500,3000,4000,5000,6000,7000,9000,12000,18000,30000);
$str = '';
foreach($salaries as $salary)
{
$str .= "<option value=\"$salary\">$salary+</option>";
}
function populateSalary()
{
$salaries = array(1000,1500,2000,2500,3000,4000,5000,6000,7000,9000,12000,18000,30000);
$str = '';
foreach($salaries as $salary)
{
$str .= "<option value=\"$salary\">$salary+</option>";
}
return $str;
}
?>
<select id="salaryExpect" name="salaryExpect">
<option value="-1">--<option>
<?php echo populateSalary(); ?>
</select>
See?There is no such empty option as <option> </option>
in the code,but strange enough there is in the output.
Can have a look here: http://maishudi.com/test3.php
Upvotes: 0
Views: 272
Reputation: 8778
Please look carefully at the first "option" in the output, you forgot to close the tag :)
Upvotes: 2
Reputation: 59653
In the line <option value="-1">--<option>
, your close tag isn't actually closing. It should read:
<option value="-1">--</option>
Upvotes: 2
Reputation: 2136
<option value="-1">--<option>
is the error , change it to
<option value="-1">--</option>
Upvotes: 3
Reputation: 22054
This line
<option value="-1">--<option>
You're not closing the tag, you're opening another, it should read
<option value="-1">--</option>
Upvotes: 9