Correct js code: // eRanConType prepares and returns Connection data fieldset export…
- User
Correct js code: // eRanConType prepares and returns Connection data fieldset export const eRanConType = (object => {
code//create port fieldset const connectionType = { legend: 'Connection Type', class: 'lte', name: 'connection', default: object.Connection, rows: object.Connections, display: 'grid', width: '50%', }.createFieldsetSelect() const conselector = connectionType.querySelector('select') conselector.addEventListener('change', (evnt) => { object.Connection = evnt.target.value }) //create port fieldset const port = { legend: 'Choose TnPort', class: 'lte', name: 'port', default: object.TnPort, rows: object.Ports, display: 'grid', width: '50%', }.createFieldsetSelect() const portselector = port.querySelector('select') portselector.addEventListener('change', (evnt) => { object.TnPort = evnt.target.value }) const check = connectionType.querySelector('select') check.addEventListener('change', (evnt) => { const key = evnt.target.value const port = { legend: 'Choose TnPort', class: 'lte', name: 'port', default: object.TnPort, rows: object.Ports, display: 'grid', width: '50%', } if (key != 'Router') { object.Vlans[key]['Vlan'] = '' port.remove() return connectionType } port.createFieldsetSelect() port.classList.add('pop-up') port.addEventListener('change', (evnt) => { object.TnPort = evnt.target.value row.appendChild(port) }) }) //return return connectionType})
- Assistant
- User
What was wrong?
- Assistant
There were a few issues with the code provided:
-
The
createFieldsetSelectfunction was not defined. I added the function definition and moved the code for creating the fieldset and select elements into this function. -
In the
check.addEventListenerfunction, there was a missing closing parenthesis afterobject.TnPort = evnt.target.value;. I added the missing parenthesis. -
In the
check.addEventListenerfunction, theport.createFieldsetSelect()line was incorrect. It should beport = createFieldsetSelect({...})instead, as we are creating a newportfieldset. -
In the
check.addEventListenerfunction, therow.appendChild(port)line was incorrectly placed inside theaddEventListenerfunction. I moved this line outside theaddEventListenerfunction. -
There were a few missing semicolons at the end of lines. I added the missing semicolons for proper syntax.
These changes should fix the issues and make the code run correctly.
-