Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Radio Button Display Stuff</title>
- <style type="text/css">
- .no-display { display: none }
- .optional-div { background: #ffc ; border: solid 1px #777 }
- </style>
- <script type="text/javascript">
- radio_display_groups = {};
- function control_display_radio(self) {
- var group_name = self.name;
- var new_value = self.value;
- model_display_radio(group_name, new_value);
- }
- function model_display_radio(group_name, new_value) {
- if (radio_display_groups[group_name]) {
- view_disable_display(group_name, radio_display_groups[group_name]);
- }
- view_enable_display(group_name, new_value);
- radio_display_groups[group_name] = new_value;
- }
- function view_enable_display(group_name, new_value) {
- document.getElementById(group_name + "_" + new_value + "_content").className = "optional-div";
- }
- function view_disable_display(group_name, new_value) {
- document.getElementById(group_name + "_" + new_value + "_content").className = "no-display";
- }
- function set_display_radio(group_name, new_value) {
- document.getElementById(group_name + "_" + new_value + "_radio").checked = "checked";
- model_display_radio(group_name, new_value);
- }
- </script>
- </head>
- <body onload="set_display_radio('abcs', 'a');">
- <p><input type="radio" name="abcs" value="a" id="abcs_a_radio" onclick="control_display_radio(this)" /> A</p>
- <p><input type="radio" name="abcs" value="b" id="abcs_b_radio" onclick="control_display_radio(this)" /> B</p>
- <p><input type="radio" name="abcs" value="c" id="abcs_c_radio" onclick="control_display_radio(this)" /> C</p>
- <p><input type="radio" name="abcs" value="d" id="abcs_d_radio" onclick="control_display_radio(this)" /> D</p>
- <p><input type="radio" name="abcs" value="e" id="abcs_e_radio" onclick="control_display_radio(this)" /> E</p>
- <p class="no-display" id="abcs_a_content">Angry Aardvarks Ate Apples</p>
- <p class="no-display" id="abcs_b_content">Brothers Belong Between Bookends</p>
- <p class="no-display" id="abcs_c_content">Canned California Creamed Corn</p>
- <p class="no-display" id="abcs_d_content">Dangerous Deeds Demand Derring-Do</p>
- <p class="no-display" id="abcs_e_content">Elephants Enrage Eastern Etruscans</p>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement