是的,这是可能的。我的表单中有一个类似于此的选项框:
<td><select name="Division" id="Division" onChange="dirChange()" tabindex="3">
<option selected>Choose One</option>
<option value="Communications">Communications</option>
<option value="Legal Services">Legal Services</option>
</select> </td>
它指的是一个javascript函数:
function dirChange()
{
var i = document.all.Division.value;
switch (i)
{
case "Communications":
document.all.DeputyDirector.value = "Dave C.";
document.all.form.action = "mailto:Dave.C@xxxxx.com?subject=Form";
break;
case "Legal Services":
document.all.DeputyDirector.value = "Dixie P.";
document.all.form.action = "mailto:Dixie.P@xxxxxx.com?subject=Form";
break;
default:
document.all.DeputyDirector.value = "";
break;
}
}
然后,此 javascript 可帮助在文本框中填写所需信息,并将表单通过电子邮件发送给选定的人。
<tr>
<td class="announcementText"> <span class="style12"><span class="style16"><span class="style31">*</span></span></span>Division Deputy Dir.: </td>
<td><input name="DeputyDirector" type="text" id="DeputyDirector" style="background-color:#cccccc; color:black; font-weight:bold; border:0; overflow:visible" size="38"></td>
</tr>
<form onChange="dirChange()" method="post" enctype="text/plain" name="form" id="form" onSubmit="return checkform(this);">
客户选择通信部门后生成的 html 为:
对于文本框:
<input name="DeputyDirector" type="text" id="DeputyDirector" style="background-color:#cccccc; color:black; font-weight:bold; border:0; overflow:visible" size="38" value = "Dave C.">
对于形式:
<form onChange="dirChange()" method="post" enctype="text/plain" name="form" id="form" onSubmit="return checkform(this); action = "mailto:Dave.C@xxxxx.com?subject=Form">
或者如果他们选择法律服务
对于文本框:
<input name="DeputyDirector" type="text" id="DeputyDirector" style="background-color:#cccccc; color:black; font-weight:bold; border:0; overflow:visible" size="38" value = "Dixie P.">
对于形式:
<form onChange="dirChange()" method="post" enctype="text/plain" name="form" id="form" onSubmit="return checkform(this); action = "mailto:Dixie.P@xxxxxx.com?subject=Form">