Кнопка формы, которая заполняет текстовое поле, не работает в Internet Explorer

0

Моя кнопка OnClick использует Javascript для заполнения двух широких текстовых полей с выбранными параметрами из нескольких блоков выбора.

Все работает отлично в Firefox и Chrome, но ничего не происходит, когда вы нажимаете кнопку в Internet Explorer. Буду признателен за любую помощь.

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

Теги:

1 ответ

0
Лучший ответ

Вы должны использовать document.getElementById('textbox1').value не просто textbox1.value.

Вот пример: http://jsfiddle.net/WbTmf/1/

Ещё вопросы

Сообщество Overcoder
Наверх
Меню