Write HTML Code to create a form containing dropdown list. This list contains colors red, green,blue and grey. Write a JavaScript code to change background color as user selected color option.
html code • 879  views

Event onChange execute JavaScript when user selects the option of a <select> element and set the background color based on selected color option.

Program :

<!DOCTYPE html>
<title>Background Color Selector</title>
<form name="bgcolorForm">
<h1>Select Background Color:</h1><br><br>
<select onChange="if(this.selectedIndex!=0)
<option value="0" selected></option>
<option value="red">Red</option>
<option value="green">Green</option>
<option value="blue">Blue</option>
<option value="grey">Grey</option>
Please log in to add an answer.

Continue reading

Find answer to specific questions by searching them here. It's the best way to discover useful content.

Find more