Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery mobile Select Multiple

I checked out all topics regarding jquery mobile select multiple and still can't figure out what's wrong with my code.

http://jsfiddle.net/HMWYu/

<!DOCTYPE html> <html>
<head>  <title>Registration</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
    <div data-role="page" id="home">
        <header data-role="header">
        <h1>Register</h1>
   </header>
         <div data-role="content">
                       <div data-role="fieldcontain">
                <label for="Services" class="ui-hidden-accessible ">
                    Services:</label>
                <select name="Services" id="Services"  multiple="multiple" size="4">
                    <option >Hotel</option>
                    <option >Transport</option>
                    <option >Others</option>
                </select>
            </div>
        </div>
            </div>
</body>
</html>

Any help would be greatly appreciated

like image 942
Frenchi In LA Avatar asked Dec 12 '22 04:12

Frenchi In LA


1 Answers

Use JQM custom select menus for multiple. http://jquerymobile.com/demos/1.0.1/docs/forms/selects/custom.html First add data-native-menu="false" to your select menu. Then make sure your options have values. I added one option that serves as a placeholder to take place of the label. Here is my sample:

<!DOCTYPE html> 
<html>
<head>
    <title>Registration</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
</head>
<body>
<div data-role="page" id="home">
   <header data-role="header">
        <h1>Register</h1>
   </header>
   <div data-role="content">
       <div data-role="fieldcontain">
           <label for="Services"  class="ui-hidden-accessible " >
               Country:
           </label>
           <select name="Services" id="Services" data-native-menu="false" data-mini="true" multiple="multiple" size="4">
               <option>Country</option>
               <option value="hotel">Hotel</option>
               <option value="transport">Transport</option>
               <option value="others">Others</option>
           </select>
       </div>
    </div>
</div>
</body>
</html>
​
like image 112
codaniel Avatar answered Feb 19 '23 07:02

codaniel