Adding id to Input and Select

Trying to programmatically change inputs (and selected options) but there is no @id on any of the input and select fields created with createInput and createSelect. Is this possible at all or do I have to create my own input controls instead ?

Hi! You can set an id by calling .id(val) on the p5.Element you create with createInput or createSelect (etc):

  let myInput = createInput();
  myInput.id("myId");  

Here’s a full example of that:

Documentation

Possible alternative

However, a lot of the time people will just keep the reference around from creation and use that directly. I expect you’re familiar with this, but here’s a demo just in case:

Thanks for the quick reply.