jQuery Mobile: Horizontal Radio Button Group

This entry is part 22 of 73 in the series jQuery Mobile

To make a horizontal button set, add the data-type=’horizontal’  to the fieldset.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'></script>
    <title>Upwhere</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header'><h1>Horizontal Radio Buttons</h1></div>
    <br>
    <p>Horizontal Radio Buttons</p>
    <form>
        <fieldset data-role='controlgroup' data-type='horizontal'>
            <input type='radio' name='radio_choice' id='radio_choice_id1' value='on' checked='checked'>
            <label for='radio_choice_id1'>One</label>
            <input type='radio' name='radio_choice' id='radio_choice_id2' value='off'>
            <label for='radio_choice_id2'>Two</label>
            <input type='radio' name='radio_choice' id='radio_choice_id3' value='other'>
            <label for='radio_choice_id3'>Three</label>
        </fieldset>
    </form>

    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code

jQuery Mobile: Vertically Grouped Radio Buttons

This entry is part 24 of 73 in the series jQuery Mobile

To integrate multiple radio buttons into a vertically grouped button set, we can use data-role=’controlgroup’>.

The code is as below.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'></script>
    <title>Codecrawl.com</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header'><h1>Vertically Grouped Radio Buttons</h1></div>
    <br>
    <p>Vertically Grouped Radio Buttons</p>
    <form>
        <fieldset data-role='controlgroup'>
            <input type='radio' name='radio_choice' id='radio_choice_id1' value='on' checked='checked'>
            <label for='radio_choice_id1'>One</label>
            <input type='radio' name='radio_choice' id='radio_choice_id2' value='off'>
            <label for='radio_choice_id2'>Two</label>
            <input type='radio' name='radio_choice' id='radio_choice_id3' value='other'>
            <label for='radio_choice_id3'>Three</label>
        </fieldset>
    </form>

    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code

In the above radio button settings, the first button is set to checked.

jQuery Mobile: Basic Radio Buttons

This entry is part 21 of 73 in the series jQuery Mobile

Radio inputs are used to provide a list of options where only a single option can be selected.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'></script>
    <title>Upwhere</title>
</head>
<body>
<div data-role='page' id='pageone'>
    <div data-role='header'><h1>Basic Radio Button</h1></div>
    <br>
    <p>Basic Radio Button</p>
    <form>
        <label><input type='radio' name='radio_choice' id='radio_choice_id1'>One</label>
        <label for='radio_choice_id2'>Two</label>
        <input type='radio' name='radio_choice' id='radio_choice_id2'>
    </form>

    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code

I have used the <label> tag so if you click on the label (one, two), it is the same as clicking on the button, toggling the selection.

jQuery Mobile: Basic Collapsible Header

This entry is part 25 of 73 in the series jQuery Mobile

To create a collapsible header, simply use data-role=’collapsible’ as the attribute.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'></script>
    <title>Upwhere</title>
</head>
<body>
<br>
<div data-role='page'>
    <div data-role='header'><h1>Collapsible</h1></div>
    <br>
    <p>You can click on me</p>
    <div data-role='collapsible'>
    <h4>Heading</h4>
    <p>I'm the collapsible content. By default I'm closed, but you can click the header to open me.</p>
</div>
    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code

jQuery Mobile: Disabled Checkbox

This entry is part 19 of 73 in the series jQuery Mobile

To disable a checkbox,  we put a disabled attribute in the html.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js'></script>
    <title>Upwhere</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header'><h1>Disabled Checkbox</h1></div>
    <br>
    <p>Disabled</p>
    <form>
        <input disabled='' type='checkbox' name='checkbox_n' id='checkbox_d' data-theme='a'>
        <label for='checkbox_d'>One</label>
    </form>

    <div data-role='footer' data-position='fixed'>
        <h1>Footer</h1>
    </div>
</div>
</body>
</html>
Try The Code