CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   HTML & CSS (http://www.codingforums.com/forumdisplay.php?f=13)
-   -   Html datalist does not work? (http://www.codingforums.com/showthread.php?t=275223)

AA Haider 10-05-2012 04:31 AM

Html datalist does not work?
 
Dear Friends,
I Hope you are all fine.
Friends,Here is a problem in HTML datalist,it does not work in
old browsers.What did can I do for fix this problem.:confused:Here is a code.
Code:

<body>
<label>What is your favorite color? <input name="color" type="text" list="html-colors"/>
  <datalist id="html-colors">
      <option value="black">Black</option>
      <option value="blue">Blue</option>
      <option value="white">White</option>
      <option value="yellow">Yellow</option>
  </datalist>
</label>
</body>


VIPStephan 10-05-2012 08:56 AM

See, that’s why HTML 5 is called a “working draft” and not “official recommendation”. One solution would be to use a select rather than a text input with datalist. After all, I don’t see the point anyway, to use a text input when the answers are a fixed set of options already.

AA Haider 10-05-2012 12:02 PM

I can not understand what are you saying?:(

VIPStephan 10-05-2012 12:31 PM

I’m saying:

Code:

<label>What is your favorite color?
  <select name="colors">
      <option value="black">Black</option>
      <option value="blue">Blue</option>
      <option value="white">White</option>
      <option value="yellow">Yellow</option>
  </select>
</label>

And by the way: A form control (input/select/textarea) must always be inside a form.

AA Haider 10-05-2012 12:49 PM

This is not my question:mad:
I say that here is a code which is work well in google chrome and firfox
new version but it can not work in IE or firfox old version.
This is a code.
Code:

<!doctype html>
<html>
<head>
<title>Example 0</title>
</head>

<body>

<p>
<form>
<label>What is your favorite color?
      <input type="text" list="colors" />
  <datalist id="colors">
      <option value="black">Black</option>
      <option value="blue">Blue</option>
      <option value="white">White</option>
      <option value="yellow">Yellow</option>
  </datalist>
</label>
</form>
</p>

</body>
</html>

Please solve this problem.

VIPStephan 10-05-2012 01:20 PM

I’m sorry, the code I provided is the solution which works in all browsers. What you have is HTML 5 which is not an official standard (yet) and, as you see, obviously not supported in all major browsers. And even if this solution doesn’t satisfy you, there is no reason to raise your voice like that because pushing buttons makes people even less willing to help you.

So, again: go with a select element and you’re all safe. As I said, there is no point in using a datalist in this context if the option are given anyway.


All times are GMT +1. The time now is 04:03 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.