Copy link to clipboard
Copied
I am getting this error:

and here is my code, that i want to create select elements (option) by JavaScript. What code i use to create Select Options?
Just Console window saying that createElement is not JavaScript function.
function AddItem(selbox, Text, Value) { // Create an Option object var opt = document.createElement("option"); // Add an Option object to Drop Down/List Box document.getElementById(selbox).options.add(opt); // Assign text and value to Option object opt.text = Text; opt.value = Value; } function load_str() { var d = new Array(); var d_v = new Array(); d[0] = '0'; d_v[0] = '0'; d[1] = '1'; d_v[1] = '1'; d[2] = '2'; d_v[2] = '2'; d[3] = '3'; d_v[3] = '3'; d[4] = '4'; d_v[4] = '4'; d[5] = '5'; d_v[5] = '5'; var frm = document.scr; for (var i = 0; i < d.length; i++) { AddItem ('cboids', d, d_v) } }
Any solutions to create Select options with JavaScript?
You can build the HTML string for the entire (updated) select element, then overwrite the object using innerHTML.
HTH,
Randy
Copy link to clipboard
Copied
You can build the HTML string for the entire (updated) select element, then overwrite the object using innerHTML.
HTH,
Randy
Copy link to clipboard
Copied
Thanks Randy for reply.
Actually here <select> element is Dynamic.
Some properties not working properly in DW.
CSS:
visibility:hidden;
visibility:visible;
display:none;
display:block;
display:inline;
Copy link to clipboard
Copied
function load_str() { visArray = new Array(); for (var i=0; i < displayNames.length; i++) { data += '<option value="' + elt_name + '">' + displayNames + "</option>\n"; } data = '<select name="cboids" id="cboids">'+'<option selected>*** Select Element ***</option>'+"\n"+data+'</select>'; document.getElementById('cboids_pl').innerHTML = data; }
I wrote this code in JavaScript and it's working 100% in DW CS5. It's create options elements via JScript without 0 errors.
Copy link to clipboard
Copied
Some properties not working properly in DW.
CSS:
visibility:hidden;
visibility:visible;
display:none;
display:block;
display:inline;
Dreamweaver Extensibility dialogs use the same rendering engine as Design View, so not all CSS is supported. Only a subset of the rendeing supported in Design View is supported in Extensibility dialogs.
The visibility property is only supported for position:absolute elements.
The display property is supported, but only the none, block, and inline values. You need to change the innerHtml property to get the dialog to re-render.
HTH,
Randy
Find more inspiration, events, and resources on the new Adobe Community
Explore Now