Skip to main content
Junaid Atari
Known Participant
May 8, 2010
Answered

createElement error. Custom DW Extention!

  • May 8, 2010
  • 1 reply
  • 1190 views

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?

This topic has been closed for replies.
Correct answer Randy Edmunds

You can build the HTML string for the entire (updated) select element, then overwrite the object using innerHTML.

HTH,

Randy

1 reply

Randy Edmunds
Adobe Employee
Randy EdmundsCorrect answer
Adobe Employee
May 12, 2010

You can build the HTML string for the entire (updated) select element, then overwrite the object using innerHTML.

HTH,

Randy

Junaid Atari
Known Participant
May 12, 2010

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;

Junaid Atari
Known Participant
May 12, 2010

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.

-- Sag-e-Attar Junaid Atari