Title: Javascript issue
Last modified: August 19, 2016

---

# Javascript issue

 *  [j_mo](https://wordpress.org/support/users/j_mo/)
 * (@j_mo)
 * [15 years, 10 months ago](https://wordpress.org/support/topic/javascript-issue-1/)
 * Hi,
 * I have used some js auto select code on a form that I have put together. It works
   fine when tested on a normal Html/PHP page but I am getting this error in WP 
   from Firebug.
 * > setting a property that has only a getter
 *  from this line:
 * > selectCtrl.options = null;
 * Has anyone got a solution? Here is the JS:
 *     ```
       team = new Array(
       new Array(
       new Array("Male")
       ),
       new Array(
       new Array("Female")
       ),
       new Array(
       new Array("Male")
       ),
       new Array(
       new Array("Female")
       )
       );
       function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
       var i, j;
       var prompt;
       for (i = selectCtrl.options.length; i >= 0; i--) {
       selectCtrl.options = null;
       }
       prompt = (itemArray != null) ? goodPrompt : badPrompt;
       if (prompt == null) {
       j = 0;
       }
       else {
       selectCtrl.options[0] = new Option(prompt);
       j = 1;
       }
       if (itemArray != null) {
       for (i = 0; i < itemArray.length; i++) {
       selectCtrl.options[j] = new Option(itemArray[0]);
       if (itemArray[1] != null) {
       selectCtrl.options[j].value = itemArray[1];
       }
       j++;
       }
       selectCtrl.options[0].selected = true;
       }
       }
       ```
   
 * My Javascript is not verygood so any help would be appreciated. Thanks
    Phil

The topic ‘Javascript issue’ is closed to new replies.

## Tags

 * [auto-populate](https://wordpress.org/support/topic-tag/auto-populate/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 0 replies
 * 1 participant
 * Last reply from: [j_mo](https://wordpress.org/support/users/j_mo/)
 * Last activity: [15 years, 10 months ago](https://wordpress.org/support/topic/javascript-issue-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
