Select select menu based on another select menu

Description

The following code shows how to select select menu based on another select menu.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.7.1.js'></script>
<script type='text/javascript'
  src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css">
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){<!--from ww  w. j  a va  2 s  .c  om-->
$(function() {
    $("#changeButton").on("click", function(e) {
        $("#entry_16").val($("#entry_14").val());
        $("#entry_16").selectmenu("refresh");
        e.preventDefault();
    });
});
});//]]>  
</script>
</head>
<body>
  <div data-role="page">
    <div data-role="content">
      <select name="entry.14.single" id="entry_14">
        <option value=""></option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
      </select> <br /> 
      <select name="entry.16.single" id="entry_16">
        <option value=""></option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
      </select> 
      <a href="#" id="changeButton">Same as Above</a>
    </div>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme