我正在尝试创建一个基本的在线表单,根据选择的内容,表格的背景颜色会更改为适当的选项值。
我遇到的问题是提交表单时提交的是选项值,而不是我需要的文本。
有没有办法修改 onChange 或者完全有更好的方法?
谢谢你的帮助。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Survey</title>
</head>
<body>
<table border="0" width="21%" cellspacing="0" cellpadding="0" height="20">
<tr>
<td id = "mycell">
<p style="margin-top: 10px; margin-bottom: 10px">
<select name="q11" <select onChange="if(this.selectedIndex!=0)
document.getElementById('mycell').bgColor=this.options[this.selectedIndex].value">
<option value="#FFFFFF">Choose a factor...
<option value="#F6B23E">My Company – feeling positive about who I work for
<option value="#F58386">My Leaders – being inspired by my business leaders
<option value="#EF3135">My Boss – mutual respect and understanding
<option value="#F58386">My Team – enjoying who I work with
<option value="#AD6AA3">My Job – enjoying what I do
<option value="#95CAA0">My Personal Growth – learning, development and prospects
<option value="#4FA761">My Deal – satisfaction with pay and benefits
<option value="#95CAA0">My Wellbeing – having a balanced life
</select></td>