0

I have an HTML <DATALIST> that depends on a second field on the page. The second field has an onchange method that builds a string of innerHTML using an SQL query and sets the innerHTML for the datalist.

document.all.MyDataList.innerHTML='<built string>’

It works. I get the right data in the data list.

But if the query finds no data and the built string is empty, I have a problem. I still see some options in the pull down list. They seem to be values that had previously been selected. I am trying to locate these ghost values.

Chrome Dev Tools shows me that the children of the datalist object has length=0. So where are the values being displayed coming from? How do I clear them?

Alon Eitan
  • 11,798
  • 8
  • 44
  • 56
  • 1
    Create [mre] to help us help you using button <> in editor to create snippet – ikiK Feb 20 '21 at 01:39
  • My question said I have an HTML [open angle bracket]DATALIST[close angle bracket] ... but the UI seems not to escape those. Also to set the innerHTML document.all.MyDataList.innerHTML='built string’ – David Loveluck Feb 20 '21 at 01:41
  • And I said show us. – ikiK Feb 20 '21 at 01:42
  • My code is written in IRIS Data Platform. I guess most people won't be familiar with that. Which is why I didn't post my code. That technology is well established and in this case not the issue. I am not asking to debug my code on the server. My question, is why when I set innerHTML to '' it leaves ghost values in the pull down menu. Is there something other than the children that can be dispalyed? – David Loveluck Feb 20 '21 at 03:31
  • Posting a minimal example would help us visualize the problem, rather than describing code in words. I don't know the answer, but it sounds like maybe you need to trigger a change event with an empty string between queries. It's possible you're not triggering onchange events in the browser when you think you are. – Sydney Y Feb 20 '21 at 03:41
  • Does this answer your question? [How do you disable browser Autocomplete on web form field / input tag?](https://stackoverflow.com/questions/2530/how-do-you-disable-browser-autocomplete-on-web-form-field-input-tag) – Alon Eitan Feb 20 '21 at 04:51

0 Answers0