Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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.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>

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,665
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I can not understand what are you saying?

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,665
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    This is not my question
    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.

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,665
    Thanks
    6
    Thanked 1,006 Times in 979 Posts
    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.

  • Users who have thanked VIPStephan for this post:

    AA Haider (10-05-2012)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •