Advertisement
Guest User

Untitled

a guest
May 1st, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.41 KB | None | 0 0
  1. <html>
  2.   <head>
  3.     <title>Radio Button Display Stuff</title>
  4.     <style type="text/css">
  5.       .no-display { display: none }
  6.       .optional-div { background: #ffc ; border: solid 1px #777 }
  7.     </style>
  8.     <script type="text/javascript">
  9.       radio_display_groups = {};
  10.  
  11.       function control_display_radio(self) {
  12.         var group_name = self.name;
  13.         var new_value = self.value;
  14.         model_display_radio(group_name, new_value);
  15.       }
  16.      
  17.       function model_display_radio(group_name, new_value) {
  18.         if (radio_display_groups[group_name]) {
  19.           view_disable_display(group_name, radio_display_groups[group_name]);
  20.         }
  21.         view_enable_display(group_name, new_value);
  22.         radio_display_groups[group_name] = new_value;
  23.       }
  24.      
  25.       function view_enable_display(group_name, new_value) {
  26.         document.getElementById(group_name + "_" + new_value + "_content").className = "optional-div";
  27.       }
  28.      
  29.       function view_disable_display(group_name, new_value) {
  30.         document.getElementById(group_name + "_" + new_value + "_content").className = "no-display";
  31.       }
  32.      
  33.       function set_display_radio(group_name, new_value) {
  34.         document.getElementById(group_name + "_" + new_value + "_radio").checked = "checked";
  35.         model_display_radio(group_name, new_value);
  36.       }
  37.     </script>
  38.   </head>
  39.   <body onload="set_display_radio('abcs', 'a');">
  40.     <p><input type="radio" name="abcs" value="a" id="abcs_a_radio" onclick="control_display_radio(this)" /> A</p>
  41.     <p><input type="radio" name="abcs" value="b" id="abcs_b_radio" onclick="control_display_radio(this)" /> B</p>
  42.     <p><input type="radio" name="abcs" value="c" id="abcs_c_radio" onclick="control_display_radio(this)" /> C</p>
  43.     <p><input type="radio" name="abcs" value="d" id="abcs_d_radio" onclick="control_display_radio(this)" /> D</p>
  44.     <p><input type="radio" name="abcs" value="e" id="abcs_e_radio" onclick="control_display_radio(this)" /> E</p>
  45.     <p class="no-display" id="abcs_a_content">Angry Aardvarks Ate Apples</p>
  46.     <p class="no-display" id="abcs_b_content">Brothers Belong Between Bookends</p>
  47.     <p class="no-display" id="abcs_c_content">Canned California Creamed Corn</p>
  48.     <p class="no-display" id="abcs_d_content">Dangerous Deeds Demand Derring-Do</p>
  49.     <p class="no-display" id="abcs_e_content">Elephants Enrage Eastern Etruscans</p>
  50.   </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement