Hide and displaying layers through radio buttonsWe can manage display or hide a part of the form based on the user selection from a radio button. One example of this is displaying contact information and at the same place displaying the contact form for the visitor to send a message. Once the visitor clicks the radio button saying contact form the contact details will be replaced with a contact form.We will be using layers defined by div tags for achieving this effect. We will use on page style sheet to assign styles for the div tag. Inside our head tags we will place one JavaScript function to manage the display style property of the div tag. So this function will receive Div tag is and display value ( inline or none ) We will use one pair of radio buttons and use its onclick event to display one div layer and hide the other div layer. Same way the other radio button will do the opposite. We kept form components inside one div layer and contact details inside other div layer. Based on requirements we can place different components and text inside different layers demo of onclick radio button and layer Here is the code
<html>
| ||||||||||||
Events Handling in JavaScript
| ||||||||||||