Javascript 填充文本框的表单按钮在Internet Explorer中不起作用
MyButtonOnClick事件使用Javascript从多个选择框中选择选项填充两个宽文本框 在Firefox和Chrome中,一切都很完美,但当你点击Internet Explorer中的按钮时,一切都没有发生。我将感谢任何帮助Javascript 填充文本框的表单按钮在Internet Explorer中不起作用,javascript,html,Javascript,Html,MyButtonOnClick事件使用Javascript从多个选择框中选择选项填充两个宽文本框 在Firefox和Chrome中,一切都很完美,但当你点击Internet Explorer中的按钮时,一切都没有发生。我将感谢任何帮助 <!DOCTYPE html> <html> <script type="text/javascript"> function addbutton1() { var box1 = document.getElementBy
<!DOCTYPE html>
<html>
<script type="text/javascript">
function addbutton1() {
var box1 = document.getElementById('dropdown1').options[document.getElementById('dropdown1').selectedIndex].text;
var box2 = document.getElementById('dropdown2').options[document.getElementById('dropdown2').selectedIndex].text;
var box3 = document.getElementById('dropdown3').options[document.getElementById('dropdown3').selectedIndex].text;
var box4 = document.getElementById('dropdown4').options[document.getElementById('dropdown4').selectedIndex].text;
var box5 = document.getElementById('dropdown5').options[document.getElementById('dropdown5').selectedIndex].text;
var box6 = document.getElementById('dropdown6').options[document.getElementById('dropdown6').selectedIndex].text;
textbox1.value = box1 + ', ' + box2 + ', ' + box3 + ', ' + box4;
textbox2.value = box5 + ', ' + box6;
}
</script>
<body>
<form name="customform" id="wstForm_Custom" action="%wstx.formmailerurl%" method="post" labelID="formLabel_CustomForm">
<style>
#wstForm_Custom {background-color:transparent;} .specialEmailField {display: none;visibility:hidden;height:0px;} .emailDisplay {display: none;visibility:hidden;height:0px;}
</style>
<table>
<tr><td style="font-family:Arial; text-align: left; font-size: 10pt;">Row 1:</td>
<td><select style="width: 150px" id="dropdown1">
<option value='0'>Select</option>
<option value='100.00'>Option 1a</option>
<option value='100.00'>Option 1b</option>
</select></td>
<td><select style="width: 150px" id="dropdown2">
<option>Select</option>
<option>Option 2a</option>
<option>Option 2b</option>
</select></td></tr>
<tr><td style="font-family:Arial; text-align: left; font-size: 10pt;">Row 2:</td>
<td><select style="width: 150px" id="dropdown3">
<option>Select</option>
<option>option 3a</option>
<option>Option 3b</option>
</select></td>
<td><select style="width: 150px" id="dropdown4">
<option>Select</option>
<option>Option 4a</option>
<option>Option 4b</option>
</select></td>
<tr><td style="font-family:Arial; text-align: left; font-size: 10pt;">Row 3:</td>
<td><select style="width: 150px" id="dropdown5">
<option value='0'>Select</option>
<option value='0'>Option 5a</option>
<option value='0'>Option 5b</option>
</select></td></tr>
<tr><td style="font-family:Arial; text-align: left; font-size: 10pt;">Row 4:</td>
<td><select style="width: 150px" id="dropdown6">
<option value='0'>Select</option>
<option value='100.00'>Option 6a</option>
<option value='100.00'>Option 6b</option>
</select></td>
</table>
<button type="button" onclick="addbutton1(this.form)">Add Options to Textboxes</button>
<table style="width: 700px">
<tr>
<input style="width:480px" name="First Textbox" id="textbox1" type="text" AUTOCOMPLETE="OFF"/></td>
</tr>
<tr>
<input style="width:480px" name="Second Textbox" id="textbox2" type="text" AUTOCOMPLETE="OFF"/></td>
</tr>
</table>
<p style="width: 740px; text-align: center">
<input style="width:100px;" title="Submit" id="wstForm_Custom_Submit" onclick="return wstxSubmitForm(this);" type="submit" value="Submit"/>
<input style="width:50px;" title="Reset Form" id="wstForm_Custom_Reset" type="reset" value="Reset"/>
</p>
</form>
</body>
函数addbutton1(){
var box1=document.getElementById('dropdown1')。选项[document.getElementById('dropdown1')。selectedIndex]。文本;
var box2=document.getElementById('dropdown2')。选项[document.getElementById('dropdown2')。selectedIndex]。文本;
var box3=document.getElementById('dropdown3')。选项[document.getElementById('dropdown3')。selectedIndex]。文本;
var box4=document.getElementById('dropdown4')。选项[document.getElementById('dropdown4')。selectedIndex]。文本;
var box5=document.getElementById('dropdown5')。选项[document.getElementById('dropdown5')。selectedIndex]。文本;
var box6=document.getElementById('dropdown6')。选项[document.getElementById('dropdown6')。selectedIndex]。文本;
textbox1.value=box1+'、'+box2+'、'+box3+'、'+box4;
textbox2.value=box5+','+box6;
}
#wstForm_自定义{背景颜色:透明;}.SpecialMailField{display:无;可见性:隐藏;高度:0px;}.emailDisplay{display:无;可见性:隐藏;高度:0px;}
第1行:
挑选
备选案文1a
备选方案1b
挑选
备选案文2a
备选方案2b
第2行:
挑选
备选案文3a
备选方案3b
挑选
备选案文4a
备选方案4b
第3行:
挑选
选项5a
备选案文5b
第4行:
挑选
备选案文6a
备选方案6b
向文本框添加选项
您应该使用
document.getElementById('textbox1').value
而不是简单的textbox1.value
以下是一个例子: