0
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
0
0

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>
<html>
<header>
<title>Background Color Selector</title>
</header>
<form name="bgcolorForm">
<center>
<h1>Select Background Color:</h1><br><br>
<select onChange="if(this.selectedIndex!=0)
document.bgColor=this.options[this.selectedIndex].value">
<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>
</select>
</center>
</form>
</html>
0
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