question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to add option element in select field.

See original GitHub issue

Hi Miguel,

Stupid question, how do you add option elements in the select field of the forms?

I looked and I noticed that it seems to use the same traits as the forms package from grapesjs plugin, but I still don’t get it.

I noticed that when dropping the select element it adds a default option.

<select class="form-control" id="i54ef"><option value="">- Select option -</option><option value="1">Option 1</option></select>

Like this, but when I click on the select element in the canvas, I don’t see the options appear in the options trait.

image

Thanks!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kaoz70commented, Mar 1, 2019

Yeah, I also thought that, maybe I can try to do something about the select’s options in the traits.

1reaction
kaoz70commented, Feb 28, 2019

Alright, so I integrated the code into the plugin, additionally you can pass the optionsStringSeparator in the config if you want to use another separator instead of the ‘::’

Default separator:

::- Select option -
1::Option 1

Custom separator:

|- Select option -
1|Option 1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding options to select with javascript - html - Stack Overflow
var firstSelect = document.getElementById('first select elements id'), secondSelect = document.getElementById('second select elements id'), ...
Read more >
HTML DOM Select add() Method - W3Schools
The add() method is used to add an option to a drop-down list. Tip: To remove an option from a drop-down list, use...
Read more >
How to Add / Remove Options of a Selection Box Dynamically
JavaScript uses the HTMLSelectElement type to represent the <select> element. · Use the add() method of the HTMLSelectElement to add an option to...
Read more >
HTMLSelectElement.add() - Web APIs | MDN
The HTMLSelectElement.add() method adds an element to the collection of option elements for this select element.
Read more >
How to Add Option to Select Tag From Input Text Using ...
For adding an option from the input text in a select tag, use the “add()” method with “Option” Constructor. The add() method is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found