How to use value from modal tinymce windowManager?

WordPress Development Asked by Patrick Paul on December 10, 2020

Hello im using a Javascript File for integrating a button with a function in my TinyMCE editor in my WordPress enviroment. I want to get the value from the select-Tag field and use it for further operations. How i can get the value which is selected?

init : function(ed, url)
              title : 'Code-Highlight',
              cmd : 'code-hightlight-cmd',
              image : url + '/prism-icon.jpg'
            ed.addCommand('code-hightlight-cmd', function()
                  title: 'Code-Highlighter',
                  width : 300,
                  height : 300,
                  html :
                      '<label>Programmiersprache:<select id="programming-language-id" name="programming-language-name" size="1"><option>ABAP</option><option>C#</option><option>CSS</option><option>HTML</option><option>Java</option><option>Javascript</option><option>PHP</option><option>SQL</option></select></label>',
                  buttons: [
                          text: 'Bestätigen',
                          onclick: function()
                              var id_id = tinymce.get('programming-language-id');
                              var id_name = tinymce.get('programming-language-name');
                              tinymce.activeEditor.execCommand('mceInsertContent', false, "some text");
                          text: 'Schließen',
                          onclick: 'close'

enter image description here

One Answer

If I read your question correctly, this is more related to Javascript programming than WordPress.

To get the selected option value or text of a HTML select tag, use:

var e = document.getElementById("programming-language-id");
var value = e.options[e.selectedIndex].value;  //your code doesn't set option value
var text = e.options[e.selectedIndex].text;  //this will get the selected option text

Answered by hcheung on December 10, 2020

Add your own answers!

Related Questions

Style WooCommerce Product Search Widget

0  Asked on December 19, 2020 by chirlet-deusa


Role – edit page but not publish

1  Asked on December 15, 2020 by miri-ull


How to create a breadcrumb for pages?

3  Asked on December 13, 2020 by msrajjc2


Weird issue with is_pages() with array

0  Asked on December 11, 2020 by birdseyedesign


WP_Query will not display draft posts

4  Asked on December 11, 2020 by ben-racicot


Flickity slider on WordPress: Modify behaviour

1  Asked on December 11, 2020 by vicdilu


Add the same content to multiple pages

1  Asked on December 10, 2020


Understanding WordPress(framework?) Web Development

2  Asked on December 10, 2020 by anuj-kaithwas


How to use value from modal tinymce windowManager?

1  Asked on December 10, 2020 by patrick-paul


wp_editor() renders outside wrapping div

0  Asked on December 9, 2020


WP REST API: Order posts by meta value (acf)?

2  Asked on December 9, 2020 by mauro-bringolf


How to incluide custom field in WooCommerce email using placeholder

0  Asked on December 8, 2020 by santiago-cuartas-rmrz


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP