473,385 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to add items to a dropdownlist control within a Javascript eventhandler?

I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?
Nov 19 '05 #1
6 16597
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?

Nov 19 '05 #2
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage Web
Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning="GridLayout">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server">naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server">kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam"></asp:TextBox>
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in bericht
news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?


Nov 19 '05 #3
Oscar,

did you check what will be rendered on your page. Do a "View Source" of the
page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP15.phx.gbl...
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage
Web Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning="GridLayout">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server">naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server">kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam"></asp:TextBox>
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?



Nov 19 '05 #4
Daniel,

You are a hero to me! I've done the view source and I saw that the ID was
rewritten as ID= UltraWebGrid1__ctl0_DropDownList1. I've changed the HTML
source to

document.getElementById("UltraWebGrid1__ctl0_DropD ownList1").options[0] =
new Option("1990", "1990");

and now it's working!

thank you very much and have a nice day.

regards,
Oscar
"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in bericht
news:u0**************@TK2MSFTNGP14.phx.gbl...
Oscar,

did you check what will be rendered on your page. Do a "View Source" of
the page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP15.phx.gbl...
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage
Web Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning="GridLayout">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server">naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server">kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam"></asp:TextBox>
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
I want to add items to a dropdownlist control within a Javascript
eventhandler.
This is what I code :

var dd = document.getElementById("DropDownList1");

dd.Items.Add("1990");
dd.Items.Add("1991");
dd.Items.Add("1992");

however, it doesn't work.

What should I code instead ?



Nov 19 '05 #5
Thanks Oscar,

Glad I could help! What you see is basically what happens. To guarantee
uniqueness all "repeater"-controls translate the ID to a progressional. ID.
Actually the tip I gave you is helpful in a lot of scenarios. Especially if
you want to know how webcontrols are "translated".

Take care
---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP09.phx.gbl...
Daniel,

You are a hero to me! I've done the view source and I saw that the ID was
rewritten as ID= UltraWebGrid1__ctl0_DropDownList1. I've changed the HTML
source to

document.getElementById("UltraWebGrid1__ctl0_DropD ownList1").options[0] =
new Option("1990", "1990");

and now it's working!

thank you very much and have a nice day.

regards,
Oscar
"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:u0**************@TK2MSFTNGP14.phx.gbl...
Oscar,

did you check what will be rendered on your page. Do a "View Source" of
the page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:ua****************@TK2MSFTNGP15.phx.gbl...
Daniel,
thanks for the advice. This solution works in case the DropDownList is
positioned free within a page.
However, In my case it is part of a Webgrid, as part of the NetAdvantage
Web Controls and within this configuration, it doesn't work.
I've attached a part of the HTML. Maybe you can find the origin of the
problem.

regards,
Oscar

<igtbl:ultrawebgrid id="UltraWebGrid1" style="Z-INDEX: 101; LEFT: 104px;
POSITION: absolute; TOP: 48px"
runat="server" Height="200px" Width="325px">
<DisplayLayout RowHeightDefault="20px" Version="4.00"
BorderCollapseDefault="Separate" Name="UltraWebGrid1">
<AddNewBox>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</AddNewBox>
<Pager>
<Style BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray">

<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White">
</BorderDetails>

</Style>
</Pager>
<HeaderStyleDefault BorderStyle="Solid" BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</HeaderStyleDefault>
<FrameStyle Width="325px" BorderWidth="1px" Font-Size="8pt"
Font-Names="Verdana" BorderStyle="Solid"
Height="200px"></FrameStyle>
<FooterStyleDefault BorderWidth="1px" BorderStyle="Solid"
BackColor="LightGray">
<BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px"
ColorLeft="White"></BorderDetails>
</FooterStyleDefault>
<ClientSideEvents
BeforeRowTemplateOpenHandler="UltraWebGrid1_Before RowTemplateOpenHandler"
AfterRowTemplateOpenHandler="UltraWebGrid1_AfterRo wTemplateOpenHandler"></ClientSideEvents>
<EditCellStyleDefault BorderWidth="0px"
BorderStyle="None"></EditCellStyleDefault>
<RowStyleDefault BorderWidth="1px" BorderColor="Gray"
BorderStyle="Solid">
<Padding Left="3px"></Padding>
<BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails>
</RowStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand AllowUpdate="RowTemplateOnly" AllowAdd="Yes">
<Columns>
<igtbl:UltraGridColumn HeaderText="naam" Key="naam"
BaseColumnName="">
<Footer Key="naam"></Footer>
<Header Key="naam" Caption="naam"></Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn HeaderText="kleur" Key="kleur"
Type="DropDownList" BaseColumnName="">
<ValueList>
<ValueListItems>
<igtbl:ValueListItem DataValue="geel" Key="geel"
DisplayText="geel"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="rood" Key="rood"
DisplayText="rood"></igtbl:ValueListItem>
<igtbl:ValueListItem DataValue="blauw" Key="blauw"
DisplayText="blauw"></igtbl:ValueListItem>
</ValueListItems>
</ValueList>
<Footer Key="kleur"></Footer>
<Header Key="kleur" Caption="kleur"></Header>
</igtbl:UltraGridColumn>
</Columns>
<RowEditTemplate>
<DIV style="WIDTH: 256px; POSITION: relative; HEIGHT: 104px"
ms_positioning="GridLayout">
<asp:Label id="Label1" style="Z-INDEX: 101; LEFT: 16px; POSITION:
absolute; TOP: 16px" runat="server">naam</asp:Label>
<asp:Label id="Label2" style="Z-INDEX: 102; LEFT: 16px; POSITION:
absolute; TOP: 56px" runat="server">kleur</asp:Label>
<asp:TextBox id="TextBox1" style="Z-INDEX: 103; LEFT: 72px;
POSITION: absolute; TOP: 16px" runat="server"
columnKey="naam"></asp:TextBox>
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 104; LEFT:
72px; POSITION: absolute; TOP: 56px"
runat="server" Width="160px"
columnKey="kleur"></asp:DropDownList></DIV>
<BR>
<P align="center"><INPUT id="igtbl_reOkBtn" style="WIDTH: 50px"
onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="OK">&nbsp; <INPUT id="igtbl_reCancelBtn"
style="WIDTH: 50px" onclick="igtbl_gRowEditButtonClick(event);"
type="button" value="Cancel"></P>
</RowEditTemplate>
<RowTemplateStyle BorderColor="White" BorderStyle="Ridge"
BackColor="White">
<BorderDetails WidthLeft="3px" WidthTop="3px" WidthRight="3px"
WidthBottom="3px"></BorderDetails>
</RowTemplateStyle>
</igtbl:UltraGridBand>
</Bands>
</igtbl:ultrawebgrid>


"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:eo**************@TK2MSFTNGP12.phx.gbl...
Oscar,

try the following:

document.getElementById("DropDownList").options[0] = new Option("1990",
"1990");

Regards

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

"Oscar" <ok*@xs4all.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
>I want to add items to a dropdownlist control within a Javascript
>eventhandler.
> This is what I code :
>
> var dd = document.getElementById("DropDownList1");
>
> dd.Items.Add("1990");
> dd.Items.Add("1991");
> dd.Items.Add("1992");
>
> however, it doesn't work.
>
> What should I code instead ?
>
>



Nov 19 '05 #6
How about using ClientID of the control, and writing out the script from
CodeBehind.
See here for an example:
http://aspnet.4guysfromrolla.com/art...91703-1.2.aspx

Look for the section "Emitting the Client-Side JavaScript"

Regards

"Oscar" <ok*@xs4all.nl> skrev i melding
news:%2****************@TK2MSFTNGP09.phx.gbl...
Daniel,

You are a hero to me! I've done the view source and I saw that the ID was
rewritten as ID= UltraWebGrid1__ctl0_DropDownList1. I've changed the HTML
source to

document.getElementById("UltraWebGrid1__ctl0_DropD ownList1").options[0] =
new Option("1990", "1990");

and now it's working!

thank you very much and have a nice day.

regards,
Oscar
"Daniel Walzenbach" <da***************@newsgroup.nospam> schreef in
bericht news:u0**************@TK2MSFTNGP14.phx.gbl...
Oscar,

did you check what will be rendered on your page. Do a "View Source" of
the page and check out the naming pattern.

Does this help?

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Santhu | last post by:
To the already present dropdownlist control can i add a property so that i can add text plus image to items. Actually my requirement is i want to add text and image to the items in the dropdownlist...
4
by: theo | last post by:
Program flow...load file,then extract the xml text tags from the file,then the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the...
2
by: Ali | last post by:
I am adding a DropDownList control to my DataGrid footer template. I load my DropDownList using a function that returns an arrayList. I can see all my items in the DropDownList, but when I select...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
1
by: Matt | last post by:
Hi. I'm using VS2005 and working with the Dropdownlist control on an ASP page. My dropdownlist has several thousand items, all integers, ranging from 1000 to 80000 (these represent different...
2
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine...
5
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc"...
7
by: =?Utf-8?B?UmVraGE=?= | last post by:
Hi, I am trying to change the font color for the items in a dropdownlist control at run time using ASP.NET 2.0. DropDownList1.Items.Attributes.Add("style", "color:red"); But when I run the...
1
by: =?Utf-8?B?aUhhdkFRdWVzdGlvbg==?= | last post by:
I have a dropdownlist of width 100px in a webform. When I hit the control, I gets the list of items that I populated in a pageload. My problem is that the items in my dropdown are more in length...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.