...

View Full Version : dynamic generated DropDOwn value not captured in IE



korssane
08-17-2011, 07:14 PM
hi Peers,

i am having issue capturing the value of the selected DDL using IE.
the code below works just fine in Firefox...


// Create a new drop down list -- for text box use 'input' instead of 'select'
var newDDL = document.createElement('select');

// size lenght of the DDL for both IE or Firefox
newDDL.setAttribute("style","width:300px");
//firefox
newDDL.setAttribute("width","300px");
newDDL.style.width = "300px";
newDDL.id = 'id' + elementid + ColumnElement;
newDDL.setAttribute('name','newDDL'+ elementid+ColumnElement);

// filling the DDL by ITEM array Elements
var i=0;
for (i=0;i<=rec_count;i++)
{
objOption = document.createElement('option')
objOption.text = ITEM[i]
newDDL.options.add(objOption)
}

counter++;
newDDL.onchange = show1;

both cases are giving the value selected in firefox

function 1:
function show1()
{
alert('id=' + this.getAttribute('id') + 'name = ' + this.getAttribute('name') + 'value=' + this.value );

}

function 2:
function show1()
{
alert('id=' + this.getAttribute('id') + 'name = ' + this.getAttribute('name') + 'value='+ this.getAttribute('value'));

}


any suggestion will be appreciated
thanks

Calvert Tripesi
08-17-2011, 10:04 PM
Try assigning a value, which I.E. expects:

for (i=0;i<=rec_count;i++) // "<=" ?
{
objOption = document.createElement('option')
objOption.text = ITEM[i];
objOption.value = ITEM[i];
newDDL.options.add(objOption);
}

korssane
08-17-2011, 11:05 PM
Thank Calvert ,

That did the job. i completely did not see that one.

thanks again



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum