Hi,
I am trying to generate a pulldown-menu with JavaScript/DOM:
The following Code works fine with Opera an Mozilla but in the IE the
width of the select element is too short:
myCurrentElemen t =
window.document .getElementsByN ame('par_role')[0];
for (var i = 0; i < optionArray.len gth; i++)
{
myNewElement =
window.document .createElement( 'option');
myNewElement.se tAttribute('val ue',
optionArray[i]["value"]);
if (optionArray[i]["selected"]==1)
{
myNewElement.se tAttribute('sel ected',
'selected');
}
myNewText =
window.document .createTextNode (optionArray[i]["label"]);
myNewElement.ap pendChild(myNew Text);
myCurrentElemen t.appendChild(m yNewElement);
}
<select size="1" name="par_role" ">
<script language="JavaS cript">
<!-- //
var j = optionArray.len gth;
optionArray[j] = new Object();
optionArray[j]["value"] = "1";
optionArray[j]["label"] = "Admin";
var j = optionArray.len gth;
optionArray[j] = new Object();
optionArray[j]["value"] = "4";
optionArray[j]["selected"] = "1";
optionArray[j]["label"] = "TEST";
// -->
</script>
If I try to set the width of the select-element with css, long labels
are cut off.
Do I have any other possibility to reset the width of the select
element?
Regards
Reinhold
I am trying to generate a pulldown-menu with JavaScript/DOM:
The following Code works fine with Opera an Mozilla but in the IE the
width of the select element is too short:
myCurrentElemen t =
window.document .getElementsByN ame('par_role')[0];
for (var i = 0; i < optionArray.len gth; i++)
{
myNewElement =
window.document .createElement( 'option');
myNewElement.se tAttribute('val ue',
optionArray[i]["value"]);
if (optionArray[i]["selected"]==1)
{
myNewElement.se tAttribute('sel ected',
'selected');
}
myNewText =
window.document .createTextNode (optionArray[i]["label"]);
myNewElement.ap pendChild(myNew Text);
myCurrentElemen t.appendChild(m yNewElement);
}
<select size="1" name="par_role" ">
<script language="JavaS cript">
<!-- //
var j = optionArray.len gth;
optionArray[j] = new Object();
optionArray[j]["value"] = "1";
optionArray[j]["label"] = "Admin";
var j = optionArray.len gth;
optionArray[j] = new Object();
optionArray[j]["value"] = "4";
optionArray[j]["selected"] = "1";
optionArray[j]["label"] = "TEST";
// -->
</script>
If I try to set the width of the select-element with css, long labels
are cut off.
Do I have any other possibility to reset the width of the select
element?
Regards
Reinhold
Comment