Home > OS >  Select option with input text
Select option with input text

Time:11-20

I try to use input text for select option and i found this script from google

<input type="text" list="airports" name="airports"> 
<datalist id="airports">
<option value="Berlin">
<option value="Los Angeles">
<option value="Moscow">
<option value="Paris">
</datalist>
<input type="submit" value="confirm">
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

Here my script before :

<?php
$first="select * from members";
$two=mysql_query($first)or die("You Die!"); ?>
<select>
<? while($three=mysql_fetch_array($two)){ ?>
<option value=<? echo $three['firstname'];?><? echo $three['firstname'];?></option>
<? } ?>
</select>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

When i combine them :

<?php
$first="select * from members";
$two=mysql_query($first)or die("You Die!"); ?>
<select>
<input type="text" list="firstname" name="firstname">
<datalist id="firstname">
<? while($three=mysql_fetch_array($two)){ ?>
<option value=<? echo $three['firstname'];?>><? echo $three['firstname'];?></option>
<? } ?>
</datalist>
</select>
<iframe name="sif3" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

it doest work t_t"

CodePudding user response:

try this:

<?php
$first="select * from members";
$two=mysql_query($first)or die("You Die!"); ?>
<select>
<input type="text" list="firstname" name="firstname">
<datalist id="firstname">
<? while($three=mysql_fetch_array($two)){ ?>
<option value="<? echo $three['firstname'];?>">
<? } ?>
</datalist>
</select>
  • Related