# Uncaught SyntaxError: Identifier 'txt' has already been declared

**URL:** https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119
**Category:** Dashboard
**Created:** [13 December 2019 18:53 UTC](https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119 "2019-12-13T18:53:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![EL\_tech](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@EL\_tech](https://discourse.nodered.org/u/EL_tech)
#### Post date: [13 December 2019 18:53 UTC](https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119/1 "2019-12-13T18:53:08Z")

</div>

Hello guys,  
In the cell of a table I want to display instead of a letter a character but in my testprogram I have problems to display correct my output.  
When I start the program it works. But when I change the x and y nothing happen...  
In the developer tools from the browser (f12) i found the error: "Uncaught SyntaxError: Identifier 'txt' has already been declared".  
I don't have other variables with the same name.  
What did I do wrong?  
Thank you so much in advance!

```auto
<!--<div ng-bind-html="msg.payload"></div>-->

<style>
        #table-test td {
            width: 40px;
            height: 40px;
        }
</style>
    
<table id="table-test">
    
        <tr>
            <td>a</td>
            <td>b</td>
            <td>c</td>
            <td>d</td>
        </tr>
        
        <tr>
            <td>e</td>
            <td>f</td>
            <td>g</td>
            <td>h</td>
        </tr>
       
        <tr>
            <td>i</td>
            <td>j</td>
            <td>k</td>
            <td>l</td>
        </tr>
</table>

<script>
    cellX = 0, cellY = 0; 
    var theTable = document.getElementById('table-test'), 
    theCell = theTable.rows[cellY].cells[cellX],
    wCell = theCell.offsetWidth, hCell = theCell.offsetHeight;
    theCell.style.position = 'relative';
    theCell.innerHTML = '';
    let txt = document.createTextNode('**');
    theCell.appendChild(txt);
</script>

```

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [13 December 2019 21:31 UTC](https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119/2 "2019-12-13T21:31:20Z")

</div>

when you call it the second time - the `let txt=` is already declared from the first time so it causes the error. You notice that you don't declare `let cellX=` or any of the other variables the same way.

---

<div class="post-metadata">

### Author: ![EL\_tech](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@EL\_tech](https://discourse.nodered.org/u/EL_tech)
#### Post date: [14 December 2019 09:41 UTC](https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119/3 "2019-12-14T09:41:34Z")

</div>

@dceejay:  
Thank you so much for your fast help.  
Now I leave out the comand "let" on the variable txt and it works.  
How I access to msg object in javascript? I found [this](https://flows.nodered.org/flow/2f1aaf0635f9bf23207152682323240a) but I' m not an excpert and so I have difficult to understand it... I get allways the error: "msg is not defined"  
How i have to write the code to access to the msg object?  
Thanks for our help!  
For example I have this testcode:

```auto
<script>
var a = msg.payload.a[1].test;
switch (a){
  case 1:
        text:"1";
        break;
case 2:
       text:"2";
      break;
}
</script>

```

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [14 December 2019 15:44 UTC](https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119/4 "2019-12-14T15:44:19Z")

</div>

> [@EL\_tech](#):
>
> How I access to msg object in javascript?

Remember that Dashboard uses Angular so the msg object is buried inside the Angular environment.

I wrote a blog post about it a long time ago:

> **[Node-RED Dashboard Template Examples (AngularJS)](https://it.knightnet.org.uk/kb/nr-qa/dashboard-template-examples/#accessing-the-msg-object)**
>
> Some examples of using AngularJS with the Node-RED Dashboard.
> Not all features of Angular are accessible via the Dashboard.

---

<div class="post-metadata">

### Author: ![EL\_tech](https://avatars.discourse-cdn.com/v4/letter/e/258eb7/32.png) [@EL\_tech](https://discourse.nodered.org/u/EL_tech)
#### Post date: [16 December 2019 19:43 UTC](https://discourse.nodered.org/t/uncaught-syntaxerror-identifier-txt-has-already-been-declared/19119/5 "2019-12-16T19:43:04Z")

</div>

@TotallyInformation:  
Thank you for your help.  
For me is AngularJS new 🥴 but I will try to understand your sourcecode on your blog and apply it to my testcode. 🤠
