Welcome, Guest

Author Topic: Unity Error DOM Exception 5  (Read 414 times)

midwinterdreams

  • Posts: 4
    • View Profile
Unity Error DOM Exception 5
« on: March 06, 2017, 09:06:46 AM »
So I am attempting to fill a Select dropdown from C# unity.  Everything seems fine but I get a Invalid Character Error: DOM Exception 5.

engine.on('pupulateLevelList', function(levelArray){
   var _select = document.getElementById("levelSelect");
   for (var i=0; i<levelArray.length; i++)
   {
      var option = document.createElement(levelArray);
      _select.add(option, _select[0]);
   }
});

Seems the issue is more with Select and Options...
« Last Edit: March 07, 2017, 03:00:09 AM by midwinterdreams »

john.v

  • Administrator
  • *****
  • Posts: 71
    • View Profile
Re: Unity Error DOM Exception 5
« Reply #1 on: March 21, 2017, 11:11:02 AM »
Hi midwinterdreams,

The createElement function - https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement - takes a string that specifies the type of element to be created.

To populate the dropdown list, first, you have to use createElement to make a new option element, assign its value and text description and then add it to the select element, like this:

Code: [Select]
engine.on('populateLevelList', function(levelArray){
   var _select = document.getElementById("levelSelect");
   for (var i=0; i<levelArray.length; i++)
   {
      console.log(levelArray[i]);
      var currentOption = document.createElement("option");
      currentOption.value = levelArray[i];
      currentOption.text = levelArray[i];
      _select.add(currentOption, _select[i]);
   }
});

Keep in mind that Coherent GT doesn't support elements that require creating a new OS window like progress bars or dropdowns. However, there are plenty of third party solutions for dropdowns. You can use this one - http://designwithpc.com/Plugins/ddSlick. It also allows for a lot more customizability and a better user experience.

John V.
Support Engineer at Coherent Labs

Tags: