This is an unnecessarily complicated way to select the contents, please change these three lines to:
```
document.getElementById('pageNumber').select();
```