filling values to dropdownlist using javascript at page load time

Discussion in 'ASP .Net Web Controls' started by deepak kumar, Oct 29, 2004.

  1. deepak kumar

    deepak kumar Guest

    i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    want that when poge loads then dropdownlist should be populate at client side
    automatically...

    ---------------------------------------------------------------------------------------------
    <script language="javascript">
    function fnPopulate()
    {
    for(int i=0;i<=29;i++)
    {
    var myValue=document.createElement("<option value='" + i + "'>" + i +
    "</option>");
    document.Form1.ddlist1.add(myValue);
    }

    }
    }

    </script
    --------------------------------------------------------------------------------------------
    deepak kumar, Oct 29, 2004
    #1
    1. Advertising

  2. deepak kumar

    J.W. Guest

    Mm....don't recall there is a add function of a selectbox.......

    Maybe try this:

    var opt = new Option(text,value,defaultSelected,selected);
    selectboxObj.options[selectboxObj.options.length] = opt;

    might help............


    "deepak kumar" wrote:

    > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > want that when poge loads then dropdownlist should be populate at client side
    > automatically...
    >
    > ---------------------------------------------------------------------------------------------
    > <script language="javascript">
    > function fnPopulate()
    > {
    > for(int i=0;i<=29;i++)
    > {
    > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > "</option>");
    > document.Form1.ddlist1.add(myValue);
    > }
    >
    > }
    > }
    >
    > </script>
    > --------------------------------------------------------------------------------------------
    J.W., Oct 29, 2004
    #2
    1. Advertising

  3. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    u r right J.W. but i need multiple values to be filled in it instead of
    single value ....when i apply for loop thenerro rcomes out as "OBJECT
    EXPECTED"..by urs code i m able to fil only when value in it and that value
    is shown on second position on dropdownlist at cleint side and my first
    posotion remains blank.. when i clik on dropdownlist at cleint side...
    plz see both problems :->1:->......how to apply FOR loop
    (i want to fill values from
    0,1, up to 29)
    :->2:->......how to set my first value on
    first
    position instead of second
    posintion finally
    (at present it comes out as
    positon 1->blank
    positon 2->0(where 0 is my
    first value)
    and u know that i m inable to fiil morte then one value in
    it..so only one value is shown on position2 whether it is 0 or any other
    value like 3,4, etc.
    i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE I
    --------------------------------------------------------------------------------------------


    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    Inherits="firstproject.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    <script language="javascript">
    function fnPopulate()
    {
    var opt = new Option(0,0,1,1);
    document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    var opt = new Option(1,1,1,1);
    document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    var opt = new Option(2,2,1,1);
    document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    var opt = new Option(3,3,1,1);
    document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    }
    </script>
    </HEAD>
    <body language="javascript" onload="fnPopulate()"
    MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    absolute; TOP: 382px" name="ddlist">
    <OPTION selected></OPTION>
    </SELECT>
    </form>
    </body>
    </HTML>

    --------------------------------------------------------------------------------------------
    "J.W." wrote:

    > Mm....don't recall there is a add function of a selectbox.......
    >
    > Maybe try this:
    >
    > var opt = new Option(text,value,defaultSelected,selected);
    > selectboxObj.options[selectboxObj.options.length] = opt;
    >
    > might help............
    >
    >
    > "deepak kumar" wrote:
    >
    > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > want that when poge loads then dropdownlist should be populate at client side
    > > automatically...
    > >
    > > ---------------------------------------------------------------------------------------------
    > > <script language="javascript">
    > > function fnPopulate()
    > > {
    > > for(int i=0;i<=29;i++)
    > > {
    > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > "</option>");
    > > document.Form1.ddlist1.add(myValue);
    > > }
    > >
    > > }
    > > }
    > >
    > > </script>
    > > --------------------------------------------------------------------------------------------
    deepak kumar, Oct 30, 2004
    #3
  4. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    done it using htmlserver ocntrol instead of webserver control ..........
    ------------------------------------------------------------------------------------------------
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    Inherits="firstproject.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    <script language="javascript">
    function fnPopulate()
    {

    for(var i=0;i<=29;i++)
    {
    var opt = new Option(i+'',0,0,0);
    document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    opt;
    }
    for(var i=0;i<=59;i++)
    {
    var opt = new Option(i+'',0,0,0);
    document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    opt;
    }
    }
    </script>
    </HEAD>
    <body language="javascript" onload="fnPopulate()"
    MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    absolute; TOP: 192px" name="ddlist1">
    <OPTION selected></OPTION>
    </SELECT>
    <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    ms_positioning="FlowLayout"><b>Day</b></DIV>
    <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    ms_positioning="FlowLayout"><b>Hour</b></DIV>
    <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    name="ddlist2">
    <OPTION selected></OPTION>
    </SELECT>
    </form>
    </body>
    </HTML>

















    -------------------------------------------------------------------------------------------------
    my code is

    "deepak kumar" wrote:

    > u r right J.W. but i need multiple values to be filled in it instead of
    > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > is shown on second position on dropdownlist at cleint side and my first
    > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > plz see both problems :->1:->......how to apply FOR loop
    > (i want to fill values from
    > 0,1, up to 29)
    > :->2:->......how to set my first value on
    > first
    > position instead of second
    > posintion finally
    > (at present it comes out as
    > positon 1->blank
    > positon 2->0(where 0 is my
    > first value)
    > and u know that i m inable to fiil morte then one value in
    > it..so only one value is shown on position2 whether it is 0 or any other
    > value like 3,4, etc.
    > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > --------------------------------------------------------------------------------------------
    >
    >
    > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > Inherits="firstproject.WebForm1" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > <HTML>
    > <HEAD>
    > <title>WebForm1</title>
    > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > <meta content="C#" name="CODE_LANGUAGE">
    > <meta content="JavaScript" name="vs_defaultClientScript">
    > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > name="vs_targetSchema">
    > <script language="javascript">
    > function fnPopulate()
    > {
    > var opt = new Option(0,0,1,1);
    > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > var opt = new Option(1,1,1,1);
    > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > var opt = new Option(2,2,1,1);
    > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > var opt = new Option(3,3,1,1);
    > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > }
    > </script>
    > </HEAD>
    > <body language="javascript" onload="fnPopulate()"
    > MS_POSITIONING="GridLayout">
    > <form id="Form1" method="post" runat="server">
    > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > absolute; TOP: 382px" name="ddlist">
    > <OPTION selected></OPTION>
    > </SELECT>
    > </form>
    > </body>
    > </HTML>
    >
    > --------------------------------------------------------------------------------------------
    > "J.W." wrote:
    >
    > > Mm....don't recall there is a add function of a selectbox.......
    > >
    > > Maybe try this:
    > >
    > > var opt = new Option(text,value,defaultSelected,selected);
    > > selectboxObj.options[selectboxObj.options.length] = opt;
    > >
    > > might help............
    > >
    > >
    > > "deepak kumar" wrote:
    > >
    > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > want that when poge loads then dropdownlist should be populate at client side
    > > > automatically...
    > > >
    > > > ---------------------------------------------------------------------------------------------
    > > > <script language="javascript">
    > > > function fnPopulate()
    > > > {
    > > > for(int i=0;i<=29;i++)
    > > > {
    > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > "</option>");
    > > > document.Form1.ddlist1.add(myValue);
    > > > }
    > > >
    > > > }
    > > > }
    > > >
    > > > </script>
    > > > --------------------------------------------------------------------------------------------
    deepak kumar, Oct 30, 2004
    #4
  5. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    now my question is ,how can i acces the values of html dropdownlist on server
    side ...
    eg. if a user at client side changes value say he select 5 number or 7
    number out of 29 numbers then the data at server side shoudl be fill in a
    table row (if we let us assume that at server side there is a table having a
    column whose value changes acording to client side htmldropdownlist number..
    eg. if 2 means monday on server side(in a table's row or column) and total
    is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    cleint side showing to user and user select 2 then
    monday should be filled at server side table in a row or column....plz J.W.
    try it and sned me urs reply with compltee code(must)(thanks once
    again)........try once ...waiting for reply here..
    "deepak kumar" wrote:

    > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > done it using htmlserver ocntrol instead of webserver control ...........
    > ------------------------------------------------------------------------------------------------
    > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > Inherits="firstproject.WebForm1" %>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > <HTML>
    > <HEAD>
    > <title>WebForm1</title>
    > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > <meta content="C#" name="CODE_LANGUAGE">
    > <meta content="JavaScript" name="vs_defaultClientScript">
    > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > name="vs_targetSchema">
    > <script language="javascript">
    > function fnPopulate()
    > {
    >
    > for(var i=0;i<=29;i++)
    > {
    > var opt = new Option(i+'',0,0,0);
    > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > opt;
    > }
    > for(var i=0;i<=59;i++)
    > {
    > var opt = new Option(i+'',0,0,0);
    > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > opt;
    > }
    > }
    > </script>
    > </HEAD>
    > <body language="javascript" onload="fnPopulate()"
    > MS_POSITIONING="GridLayout">
    > <form id="Form1" method="post" runat="server">
    > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > absolute; TOP: 192px" name="ddlist1">
    > <OPTION selected></OPTION>
    > </SELECT>
    > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > name="ddlist2">
    > <OPTION selected></OPTION>
    > </SELECT>
    > </form>
    > </body>
    > </HTML>
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > -------------------------------------------------------------------------------------------------
    > my code is
    >
    > "deepak kumar" wrote:
    >
    > > u r right J.W. but i need multiple values to be filled in it instead of
    > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > is shown on second position on dropdownlist at cleint side and my first
    > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > plz see both problems :->1:->......how to apply FOR loop
    > > (i want to fill values from
    > > 0,1, up to 29)
    > > :->2:->......how to set my first value on
    > > first
    > > position instead of second
    > > posintion finally
    > > (at present it comes out as
    > > positon 1->blank
    > > positon 2->0(where 0 is my
    > > first value)
    > > and u know that i m inable to fiil morte then one value in
    > > it..so only one value is shown on position2 whether it is 0 or any other
    > > value like 3,4, etc.
    > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > --------------------------------------------------------------------------------------------
    > >
    > >
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > Inherits="firstproject.WebForm1" %>
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > <HTML>
    > > <HEAD>
    > > <title>WebForm1</title>
    > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > <meta content="C#" name="CODE_LANGUAGE">
    > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > name="vs_targetSchema">
    > > <script language="javascript">
    > > function fnPopulate()
    > > {
    > > var opt = new Option(0,0,1,1);
    > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > var opt = new Option(1,1,1,1);
    > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > var opt = new Option(2,2,1,1);
    > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > var opt = new Option(3,3,1,1);
    > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > }
    > > </script>
    > > </HEAD>
    > > <body language="javascript" onload="fnPopulate()"
    > > MS_POSITIONING="GridLayout">
    > > <form id="Form1" method="post" runat="server">
    > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > absolute; TOP: 382px" name="ddlist">
    > > <OPTION selected></OPTION>
    > > </SELECT>
    > > </form>
    > > </body>
    > > </HTML>
    > >
    > > --------------------------------------------------------------------------------------------
    > > "J.W." wrote:
    > >
    > > > Mm....don't recall there is a add function of a selectbox.......
    > > >
    > > > Maybe try this:
    > > >
    > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > >
    > > > might help............
    > > >
    > > >
    > > > "deepak kumar" wrote:
    > > >
    > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > automatically...
    > > > >
    > > > > ---------------------------------------------------------------------------------------------
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > > for(int i=0;i<=29;i++)
    > > > > {
    > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > "</option>");
    > > > > document.Form1.ddlist1.add(myValue);
    > > > > }
    > > > >
    > > > > }
    > > > > }
    > > > >
    > > > > </script>
    > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Oct 30, 2004
    #5
  6. deepak kumar

    J.W. Guest

    RE: filling values to dropdownlist using javascript at page load t

    From your code, I don't really see why you need to populate the dropdown
    list in client side, you can do it in server side, and process what you need
    after form post back. And you can use ListBox for multiple selection.

    Here is the example:

    ==== ASPX page =========================================

    <asp:DropDownList id="DropDownList1" runat="server">
    </asp:DropDownList>

    <!-- for multiple selection if you need it -->
    <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    </asp:ListBox>

    ==== Code Behind ========================================

    protected System.Web.UI.WebControls.DropDownList DropDownList1;
    protected System.Web.UI.WebControls.ListBox ListBox1;

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    // initialize
    for(int i=0; i<30; i++)
    {
    // single selectbox
    this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));

    // multiple listbox
    this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    }
    }
    else
    {
    // post back action

    // here you can get the value from your dropdown list
    // and then you can process based on the value.
    string rtnVal = this.DropDownList1.SelectedItem.Value;
    string rtnText = this.DropDownList1.SelectedItem.Text;

    // or you get multiple selection from a ListBox
    // you can doing in a loop, or collect selected items and
    // process later
    foreach (ListItem item in this.ListBox1.Items)
    {
    if(item.Selected)
    {
    // do things here
    Message.Text += item.Text + "<br>";
    }
    }
    }
    }





    "deepak kumar" wrote:

    > now my question is ,how can i acces the values of html dropdownlist on server
    > side ...
    > eg. if a user at client side changes value say he select 5 number or 7
    > number out of 29 numbers then the data at server side shoudl be fill in a
    > table row (if we let us assume that at server side there is a table having a
    > column whose value changes acording to client side htmldropdownlist number..
    > eg. if 2 means monday on server side(in a table's row or column) and total
    > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > cleint side showing to user and user select 2 then
    > monday should be filled at server side table in a row or column....plz J.W.
    > try it and sned me urs reply with compltee code(must)(thanks once
    > again)........try once ...waiting for reply here..
    > "deepak kumar" wrote:
    >
    > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > done it using htmlserver ocntrol instead of webserver control ...........
    > > ------------------------------------------------------------------------------------------------
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > Inherits="firstproject.WebForm1" %>
    > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > <HTML>
    > > <HEAD>
    > > <title>WebForm1</title>
    > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > <meta content="C#" name="CODE_LANGUAGE">
    > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > name="vs_targetSchema">
    > > <script language="javascript">
    > > function fnPopulate()
    > > {
    > >
    > > for(var i=0;i<=29;i++)
    > > {
    > > var opt = new Option(i+'',0,0,0);
    > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > opt;
    > > }
    > > for(var i=0;i<=59;i++)
    > > {
    > > var opt = new Option(i+'',0,0,0);
    > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > opt;
    > > }
    > > }
    > > </script>
    > > </HEAD>
    > > <body language="javascript" onload="fnPopulate()"
    > > MS_POSITIONING="GridLayout">
    > > <form id="Form1" method="post" runat="server">
    > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > absolute; TOP: 192px" name="ddlist1">
    > > <OPTION selected></OPTION>
    > > </SELECT>
    > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > name="ddlist2">
    > > <OPTION selected></OPTION>
    > > </SELECT>
    > > </form>
    > > </body>
    > > </HTML>
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > >
    > > -------------------------------------------------------------------------------------------------
    > > my code is
    > >
    > > "deepak kumar" wrote:
    > >
    > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > is shown on second position on dropdownlist at cleint side and my first
    > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > plz see both problems :->1:->......how to apply FOR loop
    > > > (i want to fill values from
    > > > 0,1, up to 29)
    > > > :->2:->......how to set my first value on
    > > > first
    > > > position instead of second
    > > > posintion finally
    > > > (at present it comes out as
    > > > positon 1->blank
    > > > positon 2->0(where 0 is my
    > > > first value)
    > > > and u know that i m inable to fiil morte then one value in
    > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > value like 3,4, etc.
    > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > --------------------------------------------------------------------------------------------
    > > >
    > > >
    > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > Inherits="firstproject.WebForm1" %>
    > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > <HTML>
    > > > <HEAD>
    > > > <title>WebForm1</title>
    > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > name="vs_targetSchema">
    > > > <script language="javascript">
    > > > function fnPopulate()
    > > > {
    > > > var opt = new Option(0,0,1,1);
    > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > var opt = new Option(1,1,1,1);
    > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > var opt = new Option(2,2,1,1);
    > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > var opt = new Option(3,3,1,1);
    > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > }
    > > > </script>
    > > > </HEAD>
    > > > <body language="javascript" onload="fnPopulate()"
    > > > MS_POSITIONING="GridLayout">
    > > > <form id="Form1" method="post" runat="server">
    > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > absolute; TOP: 382px" name="ddlist">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > </form>
    > > > </body>
    > > > </HTML>
    > > >
    > > > --------------------------------------------------------------------------------------------
    > > > "J.W." wrote:
    > > >
    > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > >
    > > > > Maybe try this:
    > > > >
    > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > >
    > > > > might help............
    > > > >
    > > > >
    > > > > "deepak kumar" wrote:
    > > > >
    > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > automatically...
    > > > > >
    > > > > > ---------------------------------------------------------------------------------------------
    > > > > > <script language="javascript">
    > > > > > function fnPopulate()
    > > > > > {
    > > > > > for(int i=0;i<=29;i++)
    > > > > > {
    > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > "</option>");
    > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > }
    > > > > >
    > > > > > }
    > > > > > }
    > > > > >
    > > > > > </script>
    > > > > > --------------------------------------------------------------------------------------------
    J.W., Oct 31, 2004
    #6
  7. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    J.W., MY boss needs that dropdownlist should be filled at cient sied only
    using javascript and in no other way ...i have done what u give me in urs
    code but he refused my solution....he needs it in javascript only....and also
    if user make any changes to dropdownlist (select any particular value then
    the coressposnding values should be edited or filled in the
    table................(if he select 2 then if 2 means monday then monday
    should be filled at server sied table .that's alll..............
    plz try it

    "J.W." wrote:

    >
    > From your code, I don't really see why you need to populate the dropdown
    > list in client side, you can do it in server side, and process what you need
    > after form post back. And you can use ListBox for multiple selection.
    >
    > Here is the example:
    >
    > ==== ASPX page =========================================
    >
    > <asp:DropDownList id="DropDownList1" runat="server">
    > </asp:DropDownList>
    >
    > <!-- for multiple selection if you need it -->
    > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > </asp:ListBox>
    >
    > ==== Code Behind ========================================
    >
    > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > protected System.Web.UI.WebControls.ListBox ListBox1;
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > if(!IsPostBack)
    > {
    > // initialize
    > for(int i=0; i<30; i++)
    > {
    > // single selectbox
    > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    >
    > // multiple listbox
    > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > }
    > }
    > else
    > {
    > // post back action
    >
    > // here you can get the value from your dropdown list
    > // and then you can process based on the value.
    > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > string rtnText = this.DropDownList1.SelectedItem.Text;
    >
    > // or you get multiple selection from a ListBox
    > // you can doing in a loop, or collect selected items and
    > // process later
    > foreach (ListItem item in this.ListBox1.Items)
    > {
    > if(item.Selected)
    > {
    > // do things here
    > Message.Text += item.Text + "<br>";
    > }
    > }
    > }
    > }
    >
    >
    >
    >
    >
    > "deepak kumar" wrote:
    >
    > > now my question is ,how can i acces the values of html dropdownlist on server
    > > side ...
    > > eg. if a user at client side changes value say he select 5 number or 7
    > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > table row (if we let us assume that at server side there is a table having a
    > > column whose value changes acording to client side htmldropdownlist number..
    > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > cleint side showing to user and user select 2 then
    > > monday should be filled at server side table in a row or column....plz J.W.
    > > try it and sned me urs reply with compltee code(must)(thanks once
    > > again)........try once ...waiting for reply here..
    > > "deepak kumar" wrote:
    > >
    > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > ------------------------------------------------------------------------------------------------
    > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > Inherits="firstproject.WebForm1" %>
    > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > <HTML>
    > > > <HEAD>
    > > > <title>WebForm1</title>
    > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > name="vs_targetSchema">
    > > > <script language="javascript">
    > > > function fnPopulate()
    > > > {
    > > >
    > > > for(var i=0;i<=29;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > opt;
    > > > }
    > > > for(var i=0;i<=59;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > opt;
    > > > }
    > > > }
    > > > </script>
    > > > </HEAD>
    > > > <body language="javascript" onload="fnPopulate()"
    > > > MS_POSITIONING="GridLayout">
    > > > <form id="Form1" method="post" runat="server">
    > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > absolute; TOP: 192px" name="ddlist1">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > name="ddlist2">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > </form>
    > > > </body>
    > > > </HTML>
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > -------------------------------------------------------------------------------------------------
    > > > my code is
    > > >
    > > > "deepak kumar" wrote:
    > > >
    > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > (i want to fill values from
    > > > > 0,1, up to 29)
    > > > > :->2:->......how to set my first value on
    > > > > first
    > > > > position instead of second
    > > > > posintion finally
    > > > > (at present it comes out as
    > > > > positon 1->blank
    > > > > positon 2->0(where 0 is my
    > > > > first value)
    > > > > and u know that i m inable to fiil morte then one value in
    > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > value like 3,4, etc.
    > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > --------------------------------------------------------------------------------------------
    > > > >
    > > > >
    > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > Inherits="firstproject.WebForm1" %>
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > <HTML>
    > > > > <HEAD>
    > > > > <title>WebForm1</title>
    > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > name="vs_targetSchema">
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > > var opt = new Option(0,0,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(1,1,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(2,2,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(3,3,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > }
    > > > > </script>
    > > > > </HEAD>
    > > > > <body language="javascript" onload="fnPopulate()"
    > > > > MS_POSITIONING="GridLayout">
    > > > > <form id="Form1" method="post" runat="server">
    > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > absolute; TOP: 382px" name="ddlist">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > </form>
    > > > > </body>
    > > > > </HTML>
    > > > >
    > > > > --------------------------------------------------------------------------------------------
    > > > > "J.W." wrote:
    > > > >
    > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > >
    > > > > > Maybe try this:
    > > > > >
    > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > >
    > > > > > might help............
    > > > > >
    > > > > >
    > > > > > "deepak kumar" wrote:
    > > > > >
    > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > automatically...
    > > > > > >
    > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > <script language="javascript">
    > > > > > > function fnPopulate()
    > > > > > > {
    > > > > > > for(int i=0;i<=29;i++)
    > > > > > > {
    > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > "</option>");
    > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > }
    > > > > > >
    > > > > > > }
    > > > > > > }
    > > > > > >
    > > > > > > </script>
    > > > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Oct 31, 2004
    #7
  8. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    J.W. MY boss needs droodownlist to be filled at cleint sied only using
    javascript ............dorpdownlist should have numbers from 0 to 29 where
    all are actually days of month and if user at client sied makes changes then
    that chageg should be refleted in server sied table.......eg. if he select 3
    then it means day 3rd is seleted and if 3 means tuesday at server sied then
    tuesday should be filled on server table...plz see this probelm,i sure only u
    can do this...............

    "J.W." wrote:

    >
    > From your code, I don't really see why you need to populate the dropdown
    > list in client side, you can do it in server side, and process what you need
    > after form post back. And you can use ListBox for multiple selection.
    >
    > Here is the example:
    >
    > ==== ASPX page =========================================
    >
    > <asp:DropDownList id="DropDownList1" runat="server">
    > </asp:DropDownList>
    >
    > <!-- for multiple selection if you need it -->
    > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > </asp:ListBox>
    >
    > ==== Code Behind ========================================
    >
    > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > protected System.Web.UI.WebControls.ListBox ListBox1;
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > if(!IsPostBack)
    > {
    > // initialize
    > for(int i=0; i<30; i++)
    > {
    > // single selectbox
    > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    >
    > // multiple listbox
    > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > }
    > }
    > else
    > {
    > // post back action
    >
    > // here you can get the value from your dropdown list
    > // and then you can process based on the value.
    > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > string rtnText = this.DropDownList1.SelectedItem.Text;
    >
    > // or you get multiple selection from a ListBox
    > // you can doing in a loop, or collect selected items and
    > // process later
    > foreach (ListItem item in this.ListBox1.Items)
    > {
    > if(item.Selected)
    > {
    > // do things here
    > Message.Text += item.Text + "<br>";
    > }
    > }
    > }
    > }
    >
    >
    >
    >
    >
    > "deepak kumar" wrote:
    >
    > > now my question is ,how can i acces the values of html dropdownlist on server
    > > side ...
    > > eg. if a user at client side changes value say he select 5 number or 7
    > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > table row (if we let us assume that at server side there is a table having a
    > > column whose value changes acording to client side htmldropdownlist number..
    > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > cleint side showing to user and user select 2 then
    > > monday should be filled at server side table in a row or column....plz J.W.
    > > try it and sned me urs reply with compltee code(must)(thanks once
    > > again)........try once ...waiting for reply here..
    > > "deepak kumar" wrote:
    > >
    > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > ------------------------------------------------------------------------------------------------
    > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > Inherits="firstproject.WebForm1" %>
    > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > <HTML>
    > > > <HEAD>
    > > > <title>WebForm1</title>
    > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > name="vs_targetSchema">
    > > > <script language="javascript">
    > > > function fnPopulate()
    > > > {
    > > >
    > > > for(var i=0;i<=29;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > opt;
    > > > }
    > > > for(var i=0;i<=59;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > opt;
    > > > }
    > > > }
    > > > </script>
    > > > </HEAD>
    > > > <body language="javascript" onload="fnPopulate()"
    > > > MS_POSITIONING="GridLayout">
    > > > <form id="Form1" method="post" runat="server">
    > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > absolute; TOP: 192px" name="ddlist1">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > name="ddlist2">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > </form>
    > > > </body>
    > > > </HTML>
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > -------------------------------------------------------------------------------------------------
    > > > my code is
    > > >
    > > > "deepak kumar" wrote:
    > > >
    > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > (i want to fill values from
    > > > > 0,1, up to 29)
    > > > > :->2:->......how to set my first value on
    > > > > first
    > > > > position instead of second
    > > > > posintion finally
    > > > > (at present it comes out as
    > > > > positon 1->blank
    > > > > positon 2->0(where 0 is my
    > > > > first value)
    > > > > and u know that i m inable to fiil morte then one value in
    > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > value like 3,4, etc.
    > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > --------------------------------------------------------------------------------------------
    > > > >
    > > > >
    > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > Inherits="firstproject.WebForm1" %>
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > <HTML>
    > > > > <HEAD>
    > > > > <title>WebForm1</title>
    > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > name="vs_targetSchema">
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > > var opt = new Option(0,0,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(1,1,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(2,2,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(3,3,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > }
    > > > > </script>
    > > > > </HEAD>
    > > > > <body language="javascript" onload="fnPopulate()"
    > > > > MS_POSITIONING="GridLayout">
    > > > > <form id="Form1" method="post" runat="server">
    > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > absolute; TOP: 382px" name="ddlist">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > </form>
    > > > > </body>
    > > > > </HTML>
    > > > >
    > > > > --------------------------------------------------------------------------------------------
    > > > > "J.W." wrote:
    > > > >
    > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > >
    > > > > > Maybe try this:
    > > > > >
    > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > >
    > > > > > might help............
    > > > > >
    > > > > >
    > > > > > "deepak kumar" wrote:
    > > > > >
    > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > automatically...
    > > > > > >
    > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > <script language="javascript">
    > > > > > > function fnPopulate()
    > > > > > > {
    > > > > > > for(int i=0;i<=29;i++)
    > > > > > > {
    > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > "</option>");
    > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > }
    > > > > > >
    > > > > > > }
    > > > > > > }
    > > > > > >
    > > > > > > </script>
    > > > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Oct 31, 2004
    #8
  9. deepak kumar

    deepakkumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    "J.W." wrote:

    >
    > From your code, I don't really see why you need to populate the dropdown
    > list in client side, you can do it in server side, and process what you need
    > after form post back. And you can use ListBox for multiple selection.
    >
    > Here is the example:
    >
    > ==== ASPX page =========================================
    >
    > <asp:DropDownList id="DropDownList1" runat="server">
    > </asp:DropDownList>
    >
    > <!-- for multiple selection if you need it -->
    > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > </asp:ListBox>
    >
    > ==== Code Behind ========================================
    >
    > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > protected System.Web.UI.WebControls.ListBox ListBox1;
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > if(!IsPostBack)
    > {
    > // initialize
    > for(int i=0; i<30; i++)
    > {
    > // single selectbox
    > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    >
    > // multiple listbox
    > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > }
    > }
    > else
    > {
    > // post back action
    >
    > // here you can get the value from your dropdown list
    > // and then you can process based on the value.
    > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > string rtnText = this.DropDownList1.SelectedItem.Text;
    >
    > // or you get multiple selection from a ListBox
    > // you can doing in a loop, or collect selected items and
    > // process later
    > foreach (ListItem item in this.ListBox1.Items)
    > {
    > if(item.Selected)
    > {
    > // do things here
    > Message.Text += item.Text + "<br>";
    > }
    > }
    > }
    > }
    >
    >
    >
    >
    >
    > "deepak kumar" wrote:
    >
    > > now my question is ,how can i acces the values of html dropdownlist on server
    > > side ...
    > > eg. if a user at client side changes value say he select 5 number or 7
    > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > table row (if we let us assume that at server side there is a table having a
    > > column whose value changes acording to client side htmldropdownlist number..
    > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > cleint side showing to user and user select 2 then
    > > monday should be filled at server side table in a row or column....plz J.W.
    > > try it and sned me urs reply with compltee code(must)(thanks once
    > > again)........try once ...waiting for reply here..
    > > "deepak kumar" wrote:
    > >
    > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > ------------------------------------------------------------------------------------------------
    > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > Inherits="firstproject.WebForm1" %>
    > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > <HTML>
    > > > <HEAD>
    > > > <title>WebForm1</title>
    > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > name="vs_targetSchema">
    > > > <script language="javascript">
    > > > function fnPopulate()
    > > > {
    > > >
    > > > for(var i=0;i<=29;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > opt;
    > > > }
    > > > for(var i=0;i<=59;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > opt;
    > > > }
    > > > }
    > > > </script>
    > > > </HEAD>
    > > > <body language="javascript" onload="fnPopulate()"
    > > > MS_POSITIONING="GridLayout">
    > > > <form id="Form1" method="post" runat="server">
    > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > absolute; TOP: 192px" name="ddlist1">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > name="ddlist2">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > </form>
    > > > </body>
    > > > </HTML>
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > -------------------------------------------------------------------------------------------------
    > > > my code is
    > > >
    > > > "deepak kumar" wrote:
    > > >
    > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > (i want to fill values from
    > > > > 0,1, up to 29)
    > > > > :->2:->......how to set my first value on
    > > > > first
    > > > > position instead of second
    > > > > posintion finally
    > > > > (at present it comes out as
    > > > > positon 1->blank
    > > > > positon 2->0(where 0 is my
    > > > > first value)
    > > > > and u know that i m inable to fiil morte then one value in
    > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > value like 3,4, etc.
    > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > --------------------------------------------------------------------------------------------
    > > > >
    > > > >
    > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > Inherits="firstproject.WebForm1" %>
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > <HTML>
    > > > > <HEAD>
    > > > > <title>WebForm1</title>
    > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > name="vs_targetSchema">
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > > var opt = new Option(0,0,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(1,1,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(2,2,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(3,3,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > }
    > > > > </script>
    > > > > </HEAD>
    > > > > <body language="javascript" onload="fnPopulate()"
    > > > > MS_POSITIONING="GridLayout">
    > > > > <form id="Form1" method="post" runat="server">
    > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > absolute; TOP: 382px" name="ddlist">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > </form>
    > > > > </body>
    > > > > </HTML>
    > > > >
    > > > > --------------------------------------------------------------------------------------------
    > > > > "J.W." wrote:
    > > > >
    > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > >
    > > > > > Maybe try this:
    > > > > >
    > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > >
    > > > > > might help............
    > > > > >
    > > > > >
    > > > > > "deepak kumar" wrote:
    > > > > >
    > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > automatically...
    > > > > > >
    > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > <script language="javascript">
    > > > > > > function fnPopulate()
    > > > > > > {
    > > > > > > for(int i=0;i<=29;i++)
    > > > > > > {
    > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > "</option>");
    > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > }
    > > > > > >
    > > > > > > }
    > > > > > > }
    > > > > > >
    > > > > > > </script>
    > > > > > > --------------------------------------------------------------------------------------------
    deepakkumar, Oct 31, 2004
    #9
  10. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    "J.W." wrote:

    >
    > From your code, I don't really see why you need to populate the dropdown
    > list in client side, you can do it in server side, and process what you need
    > after form post back. And you can use ListBox for multiple selection.
    >
    > Here is the example:
    >
    > ==== ASPX page =========================================
    >
    > <asp:DropDownList id="DropDownList1" runat="server">
    > </asp:DropDownList>
    >
    > <!-- for multiple selection if you need it -->
    > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > </asp:ListBox>
    >
    > ==== Code Behind ========================================
    >
    > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > protected System.Web.UI.WebControls.ListBox ListBox1;
    >
    > private void Page_Load(object sender, System.EventArgs e)
    > {
    > if(!IsPostBack)
    > {
    > // initialize
    > for(int i=0; i<30; i++)
    > {
    > // single selectbox
    > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    >
    > // multiple listbox
    > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > }
    > }
    > else
    > {
    > // post back action
    >
    > // here you can get the value from your dropdown list
    > // and then you can process based on the value.
    > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > string rtnText = this.DropDownList1.SelectedItem.Text;
    >
    > // or you get multiple selection from a ListBox
    > // you can doing in a loop, or collect selected items and
    > // process later
    > foreach (ListItem item in this.ListBox1.Items)
    > {
    > if(item.Selected)
    > {
    > // do things here
    > Message.Text += item.Text + "<br>";
    > }
    > }
    > }
    > }
    >
    >
    >
    >
    >
    > "deepak kumar" wrote:
    >
    > > now my question is ,how can i acces the values of html dropdownlist on server
    > > side ...
    > > eg. if a user at client side changes value say he select 5 number or 7
    > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > table row (if we let us assume that at server side there is a table having a
    > > column whose value changes acording to client side htmldropdownlist number..
    > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > cleint side showing to user and user select 2 then
    > > monday should be filled at server side table in a row or column....plz J.W.
    > > try it and sned me urs reply with compltee code(must)(thanks once
    > > again)........try once ...waiting for reply here..
    > > "deepak kumar" wrote:
    > >
    > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > ------------------------------------------------------------------------------------------------
    > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > Inherits="firstproject.WebForm1" %>
    > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > <HTML>
    > > > <HEAD>
    > > > <title>WebForm1</title>
    > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > name="vs_targetSchema">
    > > > <script language="javascript">
    > > > function fnPopulate()
    > > > {
    > > >
    > > > for(var i=0;i<=29;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > opt;
    > > > }
    > > > for(var i=0;i<=59;i++)
    > > > {
    > > > var opt = new Option(i+'',0,0,0);
    > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > opt;
    > > > }
    > > > }
    > > > </script>
    > > > </HEAD>
    > > > <body language="javascript" onload="fnPopulate()"
    > > > MS_POSITIONING="GridLayout">
    > > > <form id="Form1" method="post" runat="server">
    > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > absolute; TOP: 192px" name="ddlist1">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > name="ddlist2">
    > > > <OPTION selected></OPTION>
    > > > </SELECT>
    > > > </form>
    > > > </body>
    > > > </HTML>
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > -------------------------------------------------------------------------------------------------
    > > > my code is
    > > >
    > > > "deepak kumar" wrote:
    > > >
    > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > (i want to fill values from
    > > > > 0,1, up to 29)
    > > > > :->2:->......how to set my first value on
    > > > > first
    > > > > position instead of second
    > > > > posintion finally
    > > > > (at present it comes out as
    > > > > positon 1->blank
    > > > > positon 2->0(where 0 is my
    > > > > first value)
    > > > > and u know that i m inable to fiil morte then one value in
    > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > value like 3,4, etc.
    > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > --------------------------------------------------------------------------------------------
    > > > >
    > > > >
    > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > Inherits="firstproject.WebForm1" %>
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > <HTML>
    > > > > <HEAD>
    > > > > <title>WebForm1</title>
    > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > name="vs_targetSchema">
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > > var opt = new Option(0,0,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(1,1,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(2,2,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > var opt = new Option(3,3,1,1);
    > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > }
    > > > > </script>
    > > > > </HEAD>
    > > > > <body language="javascript" onload="fnPopulate()"
    > > > > MS_POSITIONING="GridLayout">
    > > > > <form id="Form1" method="post" runat="server">
    > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > absolute; TOP: 382px" name="ddlist">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > </form>
    > > > > </body>
    > > > > </HTML>
    > > > >
    > > > > --------------------------------------------------------------------------------------------
    > > > > "J.W." wrote:
    > > > >
    > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > >
    > > > > > Maybe try this:
    > > > > >
    > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > >
    > > > > > might help............
    > > > > >
    > > > > >
    > > > > > "deepak kumar" wrote:
    > > > > >
    > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > automatically...
    > > > > > >
    > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > <script language="javascript">
    > > > > > > function fnPopulate()
    > > > > > > {
    > > > > > > for(int i=0;i<=29;i++)
    > > > > > > {
    > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > "</option>");
    > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > }
    > > > > > >
    > > > > > > }
    > > > > > > }
    > > > > > >
    > > > > > > </script>
    > > > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Oct 31, 2004
    #10
  11. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    J.W., MY boss needs that dropdownlist should be filled at cient sied only
    using javascript and in no other way ...i have done what u give me in urs
    code but he refused my solution....he needs it in javascript only....and also
    if user make any changes to dropdownlist (select any particular value then
    the coressposnding values should be edited or filled in the
    table................(if he select 2 then if 2 means monday then monday
    should be filled at server sied table .that's alll..............
    plz try it



    "deepak kumar" wrote:

    > J.W., MY boss needs that dropdownlist should be filled at cient sied only
    > using javascript and in no other way ...i have done what u give me in urs
    > code but he refused my solution....he needs it in javascript only....and also
    > if user make any changes to dropdownlist (select any particular value then
    > the coressposnding values should be edited or filled in the
    > table................(if he select 2 then if 2 means monday then monday
    > should be filled at server sied table .that's alll..............
    > plz try it
    >
    > "J.W." wrote:
    >
    > >
    > > From your code, I don't really see why you need to populate the dropdown
    > > list in client side, you can do it in server side, and process what you need
    > > after form post back. And you can use ListBox for multiple selection.
    > >
    > > Here is the example:
    > >
    > > ==== ASPX page =========================================
    > >
    > > <asp:DropDownList id="DropDownList1" runat="server">
    > > </asp:DropDownList>
    > >
    > > <!-- for multiple selection if you need it -->
    > > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > > </asp:ListBox>
    > >
    > > ==== Code Behind ========================================
    > >
    > > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > > protected System.Web.UI.WebControls.ListBox ListBox1;
    > >
    > > private void Page_Load(object sender, System.EventArgs e)
    > > {
    > > if(!IsPostBack)
    > > {
    > > // initialize
    > > for(int i=0; i<30; i++)
    > > {
    > > // single selectbox
    > > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > >
    > > // multiple listbox
    > > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > > }
    > > }
    > > else
    > > {
    > > // post back action
    > >
    > > // here you can get the value from your dropdown list
    > > // and then you can process based on the value.
    > > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > > string rtnText = this.DropDownList1.SelectedItem.Text;
    > >
    > > // or you get multiple selection from a ListBox
    > > // you can doing in a loop, or collect selected items and
    > > // process later
    > > foreach (ListItem item in this.ListBox1.Items)
    > > {
    > > if(item.Selected)
    > > {
    > > // do things here
    > > Message.Text += item.Text + "<br>";
    > > }
    > > }
    > > }
    > > }
    > >
    > >
    > >
    > >
    > >
    > > "deepak kumar" wrote:
    > >
    > > > now my question is ,how can i acces the values of html dropdownlist on server
    > > > side ...
    > > > eg. if a user at client side changes value say he select 5 number or 7
    > > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > > table row (if we let us assume that at server side there is a table having a
    > > > column whose value changes acording to client side htmldropdownlist number..
    > > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > > cleint side showing to user and user select 2 then
    > > > monday should be filled at server side table in a row or column....plz J.W.
    > > > try it and sned me urs reply with compltee code(must)(thanks once
    > > > again)........try once ...waiting for reply here..
    > > > "deepak kumar" wrote:
    > > >
    > > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > > ------------------------------------------------------------------------------------------------
    > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > Inherits="firstproject.WebForm1" %>
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > <HTML>
    > > > > <HEAD>
    > > > > <title>WebForm1</title>
    > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > name="vs_targetSchema">
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > >
    > > > > for(var i=0;i<=29;i++)
    > > > > {
    > > > > var opt = new Option(i+'',0,0,0);
    > > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > > opt;
    > > > > }
    > > > > for(var i=0;i<=59;i++)
    > > > > {
    > > > > var opt = new Option(i+'',0,0,0);
    > > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > > opt;
    > > > > }
    > > > > }
    > > > > </script>
    > > > > </HEAD>
    > > > > <body language="javascript" onload="fnPopulate()"
    > > > > MS_POSITIONING="GridLayout">
    > > > > <form id="Form1" method="post" runat="server">
    > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > > absolute; TOP: 192px" name="ddlist1">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > > name="ddlist2">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > </form>
    > > > > </body>
    > > > > </HTML>
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > -------------------------------------------------------------------------------------------------
    > > > > my code is
    > > > >
    > > > > "deepak kumar" wrote:
    > > > >
    > > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > > (i want to fill values from
    > > > > > 0,1, up to 29)
    > > > > > :->2:->......how to set my first value on
    > > > > > first
    > > > > > position instead of second
    > > > > > posintion finally
    > > > > > (at present it comes out as
    > > > > > positon 1->blank
    > > > > > positon 2->0(where 0 is my
    > > > > > first value)
    > > > > > and u know that i m inable to fiil morte then one value in
    > > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > > value like 3,4, etc.
    > > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > > --------------------------------------------------------------------------------------------
    > > > > >
    > > > > >
    > > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > > Inherits="firstproject.WebForm1" %>
    > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > > <HTML>
    > > > > > <HEAD>
    > > > > > <title>WebForm1</title>
    > > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > > name="vs_targetSchema">
    > > > > > <script language="javascript">
    > > > > > function fnPopulate()
    > > > > > {
    > > > > > var opt = new Option(0,0,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > var opt = new Option(1,1,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > var opt = new Option(2,2,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > var opt = new Option(3,3,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > }
    > > > > > </script>
    > > > > > </HEAD>
    > > > > > <body language="javascript" onload="fnPopulate()"
    > > > > > MS_POSITIONING="GridLayout">
    > > > > > <form id="Form1" method="post" runat="server">
    > > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > > absolute; TOP: 382px" name="ddlist">
    > > > > > <OPTION selected></OPTION>
    > > > > > </SELECT>
    > > > > > </form>
    > > > > > </body>
    > > > > > </HTML>
    > > > > >
    > > > > > --------------------------------------------------------------------------------------------
    > > > > > "J.W." wrote:
    > > > > >
    > > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > > >
    > > > > > > Maybe try this:
    > > > > > >
    > > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > > >
    > > > > > > might help............
    > > > > > >
    > > > > > >
    > > > > > > "deepak kumar" wrote:
    > > > > > >
    > > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > > automatically...
    > > > > > > >
    > > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > > <script language="javascript">
    > > > > > > > function fnPopulate()
    > > > > > > > {
    > > > > > > > for(int i=0;i<=29;i++)
    > > > > > > > {
    > > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > > "</option>");
    > > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > > }
    > > > > > > >
    > > > > > > > }
    > > > > > > > }
    > > > > > > >
    > > > > > > > </script>
    > > > > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Nov 1, 2004
    #11
  12. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    J.W., MY boss needs that dropdownlist should be filled at cient sied only
    using javascript and in no other way ...i have done what u give me in urs
    code but he refused my solution....he needs it in javascript only....and also
    if user make any changes to dropdownlist (select any particular value then
    the coressposnding values should be edited or filled in the
    table................(if he select 2 then if 2 means monday then monday
    should be filled at server sied table .that's alll..............
    plz try it


    "deepak kumar" wrote:

    >
    >
    > "J.W." wrote:
    >
    > >
    > > From your code, I don't really see why you need to populate the dropdown
    > > list in client side, you can do it in server side, and process what you need
    > > after form post back. And you can use ListBox for multiple selection.
    > >
    > > Here is the example:
    > >
    > > ==== ASPX page =========================================
    > >
    > > <asp:DropDownList id="DropDownList1" runat="server">
    > > </asp:DropDownList>
    > >
    > > <!-- for multiple selection if you need it -->
    > > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > > </asp:ListBox>
    > >
    > > ==== Code Behind ========================================
    > >
    > > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > > protected System.Web.UI.WebControls.ListBox ListBox1;
    > >
    > > private void Page_Load(object sender, System.EventArgs e)
    > > {
    > > if(!IsPostBack)
    > > {
    > > // initialize
    > > for(int i=0; i<30; i++)
    > > {
    > > // single selectbox
    > > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > >
    > > // multiple listbox
    > > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > > }
    > > }
    > > else
    > > {
    > > // post back action
    > >
    > > // here you can get the value from your dropdown list
    > > // and then you can process based on the value.
    > > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > > string rtnText = this.DropDownList1.SelectedItem.Text;
    > >
    > > // or you get multiple selection from a ListBox
    > > // you can doing in a loop, or collect selected items and
    > > // process later
    > > foreach (ListItem item in this.ListBox1.Items)
    > > {
    > > if(item.Selected)
    > > {
    > > // do things here
    > > Message.Text += item.Text + "<br>";
    > > }
    > > }
    > > }
    > > }
    > >
    > >
    > >
    > >
    > >
    > > "deepak kumar" wrote:
    > >
    > > > now my question is ,how can i acces the values of html dropdownlist on server
    > > > side ...
    > > > eg. if a user at client side changes value say he select 5 number or 7
    > > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > > table row (if we let us assume that at server side there is a table having a
    > > > column whose value changes acording to client side htmldropdownlist number..
    > > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > > cleint side showing to user and user select 2 then
    > > > monday should be filled at server side table in a row or column....plz J.W.
    > > > try it and sned me urs reply with compltee code(must)(thanks once
    > > > again)........try once ...waiting for reply here..
    > > > "deepak kumar" wrote:
    > > >
    > > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > > ------------------------------------------------------------------------------------------------
    > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > Inherits="firstproject.WebForm1" %>
    > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > <HTML>
    > > > > <HEAD>
    > > > > <title>WebForm1</title>
    > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > name="vs_targetSchema">
    > > > > <script language="javascript">
    > > > > function fnPopulate()
    > > > > {
    > > > >
    > > > > for(var i=0;i<=29;i++)
    > > > > {
    > > > > var opt = new Option(i+'',0,0,0);
    > > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > > opt;
    > > > > }
    > > > > for(var i=0;i<=59;i++)
    > > > > {
    > > > > var opt = new Option(i+'',0,0,0);
    > > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > > opt;
    > > > > }
    > > > > }
    > > > > </script>
    > > > > </HEAD>
    > > > > <body language="javascript" onload="fnPopulate()"
    > > > > MS_POSITIONING="GridLayout">
    > > > > <form id="Form1" method="post" runat="server">
    > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > > absolute; TOP: 192px" name="ddlist1">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > > name="ddlist2">
    > > > > <OPTION selected></OPTION>
    > > > > </SELECT>
    > > > > </form>
    > > > > </body>
    > > > > </HTML>
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > -------------------------------------------------------------------------------------------------
    > > > > my code is
    > > > >
    > > > > "deepak kumar" wrote:
    > > > >
    > > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > > (i want to fill values from
    > > > > > 0,1, up to 29)
    > > > > > :->2:->......how to set my first value on
    > > > > > first
    > > > > > position instead of second
    > > > > > posintion finally
    > > > > > (at present it comes out as
    > > > > > positon 1->blank
    > > > > > positon 2->0(where 0 is my
    > > > > > first value)
    > > > > > and u know that i m inable to fiil morte then one value in
    > > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > > value like 3,4, etc.
    > > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > > --------------------------------------------------------------------------------------------
    > > > > >
    > > > > >
    > > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > > Inherits="firstproject.WebForm1" %>
    > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > > <HTML>
    > > > > > <HEAD>
    > > > > > <title>WebForm1</title>
    > > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > > name="vs_targetSchema">
    > > > > > <script language="javascript">
    > > > > > function fnPopulate()
    > > > > > {
    > > > > > var opt = new Option(0,0,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > var opt = new Option(1,1,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > var opt = new Option(2,2,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > var opt = new Option(3,3,1,1);
    > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > }
    > > > > > </script>
    > > > > > </HEAD>
    > > > > > <body language="javascript" onload="fnPopulate()"
    > > > > > MS_POSITIONING="GridLayout">
    > > > > > <form id="Form1" method="post" runat="server">
    > > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > > absolute; TOP: 382px" name="ddlist">
    > > > > > <OPTION selected></OPTION>
    > > > > > </SELECT>
    > > > > > </form>
    > > > > > </body>
    > > > > > </HTML>
    > > > > >
    > > > > > --------------------------------------------------------------------------------------------
    > > > > > "J.W." wrote:
    > > > > >
    > > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > > >
    > > > > > > Maybe try this:
    > > > > > >
    > > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > > >
    > > > > > > might help............
    > > > > > >
    > > > > > >
    > > > > > > "deepak kumar" wrote:
    > > > > > >
    > > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > > automatically...
    > > > > > > >
    > > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > > <script language="javascript">
    > > > > > > > function fnPopulate()
    > > > > > > > {
    > > > > > > > for(int i=0;i<=29;i++)
    > > > > > > > {
    > > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > > "</option>");
    > > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > > }
    > > > > > > >
    > > > > > > > }
    > > > > > > > }
    > > > > > > >
    > > > > > > > </script>
    > > > > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Nov 1, 2004
    #12
  13. deepak kumar

    J.W. Guest

    RE: filling values to dropdownlist using javascript at page load t

    may I know what's the reason he needs to populate the drop down list on
    client side? It is kind of complicating things and wasting the power of
    asp.net. beside, if you want to fill in some data based on user's selection,
    it still need to post back and process on server. I don't think you can
    populate a server-side table using javascipt...

    J.W.


    "deepak kumar" wrote:

    > J.W., MY boss needs that dropdownlist should be filled at cient sied only
    > using javascript and in no other way ...i have done what u give me in urs
    > code but he refused my solution....he needs it in javascript only....and also
    > if user make any changes to dropdownlist (select any particular value then
    > the coressposnding values should be edited or filled in the
    > table................(if he select 2 then if 2 means monday then monday
    > should be filled at server sied table .that's alll..............
    > plz try it
    >
    >
    > "deepak kumar" wrote:
    >
    > >
    > >
    > > "J.W." wrote:
    > >
    > > >
    > > > From your code, I don't really see why you need to populate the dropdown
    > > > list in client side, you can do it in server side, and process what you need
    > > > after form post back. And you can use ListBox for multiple selection.
    > > >
    > > > Here is the example:
    > > >
    > > > ==== ASPX page =========================================
    > > >
    > > > <asp:DropDownList id="DropDownList1" runat="server">
    > > > </asp:DropDownList>
    > > >
    > > > <!-- for multiple selection if you need it -->
    > > > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > > > </asp:ListBox>
    > > >
    > > > ==== Code Behind ========================================
    > > >
    > > > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > > > protected System.Web.UI.WebControls.ListBox ListBox1;
    > > >
    > > > private void Page_Load(object sender, System.EventArgs e)
    > > > {
    > > > if(!IsPostBack)
    > > > {
    > > > // initialize
    > > > for(int i=0; i<30; i++)
    > > > {
    > > > // single selectbox
    > > > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > > >
    > > > // multiple listbox
    > > > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > > > }
    > > > }
    > > > else
    > > > {
    > > > // post back action
    > > >
    > > > // here you can get the value from your dropdown list
    > > > // and then you can process based on the value.
    > > > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > > > string rtnText = this.DropDownList1.SelectedItem.Text;
    > > >
    > > > // or you get multiple selection from a ListBox
    > > > // you can doing in a loop, or collect selected items and
    > > > // process later
    > > > foreach (ListItem item in this.ListBox1.Items)
    > > > {
    > > > if(item.Selected)
    > > > {
    > > > // do things here
    > > > Message.Text += item.Text + "<br>";
    > > > }
    > > > }
    > > > }
    > > > }
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > "deepak kumar" wrote:
    > > >
    > > > > now my question is ,how can i acces the values of html dropdownlist on server
    > > > > side ...
    > > > > eg. if a user at client side changes value say he select 5 number or 7
    > > > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > > > table row (if we let us assume that at server side there is a table having a
    > > > > column whose value changes acording to client side htmldropdownlist number..
    > > > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > > > cleint side showing to user and user select 2 then
    > > > > monday should be filled at server side table in a row or column....plz J.W.
    > > > > try it and sned me urs reply with compltee code(must)(thanks once
    > > > > again)........try once ...waiting for reply here..
    > > > > "deepak kumar" wrote:
    > > > >
    > > > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > > > ------------------------------------------------------------------------------------------------
    > > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > > Inherits="firstproject.WebForm1" %>
    > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > > <HTML>
    > > > > > <HEAD>
    > > > > > <title>WebForm1</title>
    > > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > > name="vs_targetSchema">
    > > > > > <script language="javascript">
    > > > > > function fnPopulate()
    > > > > > {
    > > > > >
    > > > > > for(var i=0;i<=29;i++)
    > > > > > {
    > > > > > var opt = new Option(i+'',0,0,0);
    > > > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > > > opt;
    > > > > > }
    > > > > > for(var i=0;i<=59;i++)
    > > > > > {
    > > > > > var opt = new Option(i+'',0,0,0);
    > > > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > > > opt;
    > > > > > }
    > > > > > }
    > > > > > </script>
    > > > > > </HEAD>
    > > > > > <body language="javascript" onload="fnPopulate()"
    > > > > > MS_POSITIONING="GridLayout">
    > > > > > <form id="Form1" method="post" runat="server">
    > > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > > > absolute; TOP: 192px" name="ddlist1">
    > > > > > <OPTION selected></OPTION>
    > > > > > </SELECT>
    > > > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > > > name="ddlist2">
    > > > > > <OPTION selected></OPTION>
    > > > > > </SELECT>
    > > > > > </form>
    > > > > > </body>
    > > > > > </HTML>
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > >
    > > > > > -------------------------------------------------------------------------------------------------
    > > > > > my code is
    > > > > >
    > > > > > "deepak kumar" wrote:
    > > > > >
    > > > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > > > (i want to fill values from
    > > > > > > 0,1, up to 29)
    > > > > > > :->2:->......how to set my first value on
    > > > > > > first
    > > > > > > position instead of second
    > > > > > > posintion finally
    > > > > > > (at present it comes out as
    > > > > > > positon 1->blank
    > > > > > > positon 2->0(where 0 is my
    > > > > > > first value)
    > > > > > > and u know that i m inable to fiil morte then one value in
    > > > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > > > value like 3,4, etc.
    > > > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > > > --------------------------------------------------------------------------------------------
    > > > > > >
    > > > > > >
    > > > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > > > Inherits="firstproject.WebForm1" %>
    > > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > > > <HTML>
    > > > > > > <HEAD>
    > > > > > > <title>WebForm1</title>
    > > > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > > > name="vs_targetSchema">
    > > > > > > <script language="javascript">
    > > > > > > function fnPopulate()
    > > > > > > {
    > > > > > > var opt = new Option(0,0,1,1);
    > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > var opt = new Option(1,1,1,1);
    > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > var opt = new Option(2,2,1,1);
    > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > var opt = new Option(3,3,1,1);
    > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > }
    > > > > > > </script>
    > > > > > > </HEAD>
    > > > > > > <body language="javascript" onload="fnPopulate()"
    > > > > > > MS_POSITIONING="GridLayout">
    > > > > > > <form id="Form1" method="post" runat="server">
    > > > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > > > absolute; TOP: 382px" name="ddlist">
    > > > > > > <OPTION selected></OPTION>
    > > > > > > </SELECT>
    > > > > > > </form>
    > > > > > > </body>
    > > > > > > </HTML>
    > > > > > >
    > > > > > > --------------------------------------------------------------------------------------------
    > > > > > > "J.W." wrote:
    > > > > > >
    > > > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > > > >
    > > > > > > > Maybe try this:
    > > > > > > >
    > > > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > > > >
    > > > > > > > might help............
    > > > > > > >
    > > > > > > >
    > > > > > > > "deepak kumar" wrote:
    > > > > > > >
    > > > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > > > automatically...
    > > > > > > > >
    > > > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > > > <script language="javascript">
    > > > > > > > > function fnPopulate()
    > > > > > > > > {
    > > > > > > > > for(int i=0;i<=29;i++)
    > > > > > > > > {
    > > > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > > > "</option>");
    > > > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > > > }
    > > > > > > > >
    > > > > > > > > }
    > > > > > > > > }
    > > > > > > > >
    > > > > > > > > </script>
    > > > > > > > > --------------------------------------------------------------------------------------------
    J.W., Nov 4, 2004
    #13
  14. deepak kumar

    deepak kumar Guest

    RE: filling values to dropdownlist using javascript at page load t

    Ok, i have tallked to her(boss) but she needs it in javascript and i have
    done it , but now i m facing some new probelm as my solution is not 100%
    complete up to now...........i have a html dropdownlist control which is
    populating using javascript at pageload time..now i want to transfer (insert)
    the item(i.e. text )of dropdownlist item (which is showing at index =0 ) to a
    table in database.how can i do
    it......i drag and drop htmltextbox control on form and save value in it
    usign javascript and then by putting text box as run as server control ,
    used the value in code behind file and using insert query successfully
    tarnsferd it in database... but the problem must be solve(according to
    cpmpany requirments) without using any control(HTML, WEBSERVER CONTROL) on
    form .so how can i do it .can i use request.querystring(). or not .or i can
    use any other technique.....and
    if yes then how......plz show me.............
    in one senetnce my probelm is "HOW TO PASS VALUE OF HTMLDROPDOWMLIST IN CODE
    BEHIND FILE WIHTOUT USING ANY CONTROL(HTML,WEBSERVER CONTROL AND TAKING VALUE
    IN IT.)?"...MY RECENT CODE IS...................
    ---------------------------------------------------------------------------------------------------------------------
    <%@ Page language="c#" Codebehind="WebForm2.aspx.cs"
    AutoEventWireup="false" Inherits="foruthpro.WebForm2" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    <script language="javascript">
    function fnPopulate()
    {
    var newOpt;
    var Hrs;
    var min;
    var getIndex;
    var lstItem;
    var today = new Date();
    Hrs = today.getHours(); //get system Time in hrs
    min = today.getMinutes();//get system Time in hrs
    for (var i=0;i<=23;i++)
    {
    newOpt = new Option;
    newOpt.value = i;
    newOpt.text = i;
    document.Form1.Select2.add(newOpt);
    }
    document.Form1.Select2.remove(0);
    for (var i=0 ; i<=23 ; i++)
    {
    if (document.Form1.Select2.options.value == Hrs)
    {
    getIndex= i;
    break;
    }
    }
    //by default current system time is focussed
    document.Form1.Select2.selectedIndex = getIndex;
    for (var i=0;i<=59;i++)
    {
    newOpt = new Option;
    newOpt.value = i;
    newOpt.text = i;
    document.Form1.Select3.add(newOpt);
    }
    document.Form1.Select3.remove(0);
    for (var i=0 ; i<=59 ; i++)
    {
    if (document.Form1.Select3.options.value == min)
    {
    getIndex= i;
    break;
    }
    }
    document.Form1.Select3.selectedIndex = getIndex;

    }//end of fnPopulate()
    function fn()
    {
    var rtnHour=document.Form1.Select2.value;
    var rtnMin=document.Form1.Select3.value;
    document.Form1.Text1.value=rtnHour;
    document.Form1.Text2.value=rtnMin;
    }

    </script>
    </HEAD>
    <body onload="fnPopulate(),fn()" MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <SELECT id="Select2" style="Z-INDEX: 101; LEFT: 152px; POSITION:
    absolute; TOP: 112px" onclick="fn()"
    runat="server">
    <OPTION selected></OPTION>
    </SELECT><SELECT id="Select3" style="Z-INDEX: 102; LEFT: 152px; WIDTH:
    24px; POSITION: absolute; TOP: 152px"
    onclick="fn()" runat="server">
    <OPTION selected></OPTION>
    </SELECT>
    <asp:button id="Button1" style="Z-INDEX: 103; LEFT: 96px; POSITION:
    absolute; TOP: 240px" runat="server"
    Text="Set Crawl-->"></asp:button><INPUT id="Text1" style="Z-INDEX: 104;
    LEFT: 64px; POSITION: absolute; TOP: 320px" type="text"
    runat="server"><INPUT id="Text2" style="Z-INDEX: 105; LEFT: 64px;
    POSITION: absolute; TOP: 352px" type="text"
    runat="server">
    <DIV style="DISPLAY: inline; Z-INDEX: 106; LEFT: 40px; WIDTH: 70px;
    POSITION: absolute; TOP: 112px; HEIGHT: 15px"
    ms_positioning="FlowLayout"><b>Hours</b></DIV>
    <DIV style="DISPLAY: inline; Z-INDEX: 107; LEFT: 40px; WIDTH: 70px;
    POSITION: absolute; TOP: 152px; HEIGHT: 15px"
    ms_positioning="FlowLayout"><b>Minutes</b></DIV>
    </form>
    </body>
    </HTML>
    ---------------AND
    --------------
    private void Button1_Click(object sender, System.EventArgs e)
    {
    ViewState["Hours"]=Text1.Value;
    ViewState["Minutes"]=Text2.Value;
    str1=Convert.ToString(ViewState["Hours"]);
    str2=Convert.ToString(ViewState["Minutes"]);
    fnFill();
    }

    ---------------------------------------------------------------------------------------------------------------------

    "J.W." wrote:

    > may I know what's the reason he needs to populate the drop down list on
    > client side? It is kind of complicating things and wasting the power of
    > asp.net. beside, if you want to fill in some data based on user's selection,
    > it still need to post back and process on server. I don't think you can
    > populate a server-side table using javascipt...
    >
    > J.W.
    >
    >
    > "deepak kumar" wrote:
    >
    > > J.W., MY boss needs that dropdownlist should be filled at cient sied only
    > > using javascript and in no other way ...i have done what u give me in urs
    > > code but he refused my solution....he needs it in javascript only....and also
    > > if user make any changes to dropdownlist (select any particular value then
    > > the coressposnding values should be edited or filled in the
    > > table................(if he select 2 then if 2 means monday then monday
    > > should be filled at server sied table .that's alll..............
    > > plz try it
    > >
    > >
    > > "deepak kumar" wrote:
    > >
    > > >
    > > >
    > > > "J.W." wrote:
    > > >
    > > > >
    > > > > From your code, I don't really see why you need to populate the dropdown
    > > > > list in client side, you can do it in server side, and process what you need
    > > > > after form post back. And you can use ListBox for multiple selection.
    > > > >
    > > > > Here is the example:
    > > > >
    > > > > ==== ASPX page =========================================
    > > > >
    > > > > <asp:DropDownList id="DropDownList1" runat="server">
    > > > > </asp:DropDownList>
    > > > >
    > > > > <!-- for multiple selection if you need it -->
    > > > > <asp:ListBox id="ListBox1" runat="server" SelectionMode="Multiple">
    > > > > </asp:ListBox>
    > > > >
    > > > > ==== Code Behind ========================================
    > > > >
    > > > > protected System.Web.UI.WebControls.DropDownList DropDownList1;
    > > > > protected System.Web.UI.WebControls.ListBox ListBox1;
    > > > >
    > > > > private void Page_Load(object sender, System.EventArgs e)
    > > > > {
    > > > > if(!IsPostBack)
    > > > > {
    > > > > // initialize
    > > > > for(int i=0; i<30; i++)
    > > > > {
    > > > > // single selectbox
    > > > > this.DropDownList1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > > > >
    > > > > // multiple listbox
    > > > > this.ListBox1.Items.Add(new ListItem(i.ToString(),i.ToString()));
    > > > > }
    > > > > }
    > > > > else
    > > > > {
    > > > > // post back action
    > > > >
    > > > > // here you can get the value from your dropdown list
    > > > > // and then you can process based on the value.
    > > > > string rtnVal = this.DropDownList1.SelectedItem.Value;
    > > > > string rtnText = this.DropDownList1.SelectedItem.Text;
    > > > >
    > > > > // or you get multiple selection from a ListBox
    > > > > // you can doing in a loop, or collect selected items and
    > > > > // process later
    > > > > foreach (ListItem item in this.ListBox1.Items)
    > > > > {
    > > > > if(item.Selected)
    > > > > {
    > > > > // do things here
    > > > > Message.Text += item.Text + "<br>";
    > > > > }
    > > > > }
    > > > > }
    > > > > }
    > > > >
    > > > >
    > > > >
    > > > >
    > > > >
    > > > > "deepak kumar" wrote:
    > > > >
    > > > > > now my question is ,how can i acces the values of html dropdownlist on server
    > > > > > side ...
    > > > > > eg. if a user at client side changes value say he select 5 number or 7
    > > > > > number out of 29 numbers then the data at server side shoudl be fill in a
    > > > > > table row (if we let us assume that at server side there is a table having a
    > > > > > column whose value changes acording to client side htmldropdownlist number..
    > > > > > eg. if 2 means monday on server side(in a table's row or column) and total
    > > > > > is 30 days in a month and our numbes in htmldropdownlist is 0,......29 at
    > > > > > cleint side showing to user and user select 2 then
    > > > > > monday should be filled at server side table in a row or column....plz J.W.
    > > > > > try it and sned me urs reply with compltee code(must)(thanks once
    > > > > > again)........try once ...waiting for reply here..
    > > > > > "deepak kumar" wrote:
    > > > > >
    > > > > > > ya J.W.,my Friend i have done it by myself after writing my query ,,but i
    > > > > > > done it using htmlserver ocntrol instead of webserver control ...........
    > > > > > > ------------------------------------------------------------------------------------------------
    > > > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > > > Inherits="firstproject.WebForm1" %>
    > > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > > > <HTML>
    > > > > > > <HEAD>
    > > > > > > <title>WebForm1</title>
    > > > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > > > name="vs_targetSchema">
    > > > > > > <script language="javascript">
    > > > > > > function fnPopulate()
    > > > > > > {
    > > > > > >
    > > > > > > for(var i=0;i<=29;i++)
    > > > > > > {
    > > > > > > var opt = new Option(i+'',0,0,0);
    > > > > > > document.Form1.ddlist1.options[document.Form1.ddlist1.options.length] =
    > > > > > > opt;
    > > > > > > }
    > > > > > > for(var i=0;i<=59;i++)
    > > > > > > {
    > > > > > > var opt = new Option(i+'',0,0,0);
    > > > > > > document.Form1.ddlist2.options[document.Form1.ddlist2.options.length] =
    > > > > > > opt;
    > > > > > > }
    > > > > > > }
    > > > > > > </script>
    > > > > > > </HEAD>
    > > > > > > <body language="javascript" onload="fnPopulate()"
    > > > > > > MS_POSITIONING="GridLayout">
    > > > > > > <form id="Form1" method="post" runat="server">
    > > > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 158px; POSITION:
    > > > > > > absolute; TOP: 192px" name="ddlist1">
    > > > > > > <OPTION selected></OPTION>
    > > > > > > </SELECT>
    > > > > > > <DIV style="DISPLAY: inline; Z-INDEX: 102; LEFT: 58px; WIDTH: 70px;
    > > > > > > POSITION: absolute; TOP: 192px; HEIGHT: 15px"
    > > > > > > ms_positioning="FlowLayout"><b>Day</b></DIV>
    > > > > > > <DIV style="DISPLAY: inline; Z-INDEX: 103; LEFT: 241px; WIDTH: 70px;
    > > > > > > POSITION: absolute; TOP: 193px; HEIGHT: 15px"
    > > > > > > ms_positioning="FlowLayout"><b>Hour</b></DIV>
    > > > > > > <SELECT style="Z-INDEX: 104; LEFT: 318px; POSITION: absolute; TOP: 191px"
    > > > > > > name="ddlist2">
    > > > > > > <OPTION selected></OPTION>
    > > > > > > </SELECT>
    > > > > > > </form>
    > > > > > > </body>
    > > > > > > </HTML>
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > >
    > > > > > > -------------------------------------------------------------------------------------------------
    > > > > > > my code is
    > > > > > >
    > > > > > > "deepak kumar" wrote:
    > > > > > >
    > > > > > > > u r right J.W. but i need multiple values to be filled in it instead of
    > > > > > > > single value ....when i apply for loop thenerro rcomes out as "OBJECT
    > > > > > > > EXPECTED"..by urs code i m able to fil only when value in it and that value
    > > > > > > > is shown on second position on dropdownlist at cleint side and my first
    > > > > > > > posotion remains blank.. when i clik on dropdownlist at cleint side...
    > > > > > > > plz see both problems :->1:->......how to apply FOR loop
    > > > > > > > (i want to fill values from
    > > > > > > > 0,1, up to 29)
    > > > > > > > :->2:->......how to set my first value on
    > > > > > > > first
    > > > > > > > position instead of second
    > > > > > > > posintion finally
    > > > > > > > (at present it comes out as
    > > > > > > > positon 1->blank
    > > > > > > > positon 2->0(where 0 is my
    > > > > > > > first value)
    > > > > > > > and u know that i m inable to fiil morte then one value in
    > > > > > > > it..so only one value is shown on position2 whether it is 0 or any other
    > > > > > > > value like 3,4, etc.
    > > > > > > > i want to generate list like 0,1,2,3,4,5,....uo to 29.......J.W. PLZ SEE IT
    > > > > > > > MY FRIEND ONCE AGAIN AND AT THIS TIME SEND ME URS CODE OF ASPX PAGE TO CALL
    > > > > > > > IT ON PAGE LOAD TIME ...AT PRESENT J.W. MY CODE IS
    > > > > > > > --------------------------------------------------------------------------------------------
    > > > > > > >
    > > > > > > >
    > > > > > > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
    > > > > > > > Inherits="firstproject.WebForm1" %>
    > > > > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    > > > > > > > <HTML>
    > > > > > > > <HEAD>
    > > > > > > > <title>WebForm1</title>
    > > > > > > > <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
    > > > > > > > <meta content="C#" name="CODE_LANGUAGE">
    > > > > > > > <meta content="JavaScript" name="vs_defaultClientScript">
    > > > > > > > <meta content="http://schemas.microsoft.com/intellisense/ie5"
    > > > > > > > name="vs_targetSchema">
    > > > > > > > <script language="javascript">
    > > > > > > > function fnPopulate()
    > > > > > > > {
    > > > > > > > var opt = new Option(0,0,1,1);
    > > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > > var opt = new Option(1,1,1,1);
    > > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > > var opt = new Option(2,2,1,1);
    > > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > > var opt = new Option(3,3,1,1);
    > > > > > > > document.Form1.ddlist.options[document.Form1.ddlist.options.length] = opt;
    > > > > > > > }
    > > > > > > > </script>
    > > > > > > > </HEAD>
    > > > > > > > <body language="javascript" onload="fnPopulate()"
    > > > > > > > MS_POSITIONING="GridLayout">
    > > > > > > > <form id="Form1" method="post" runat="server">
    > > > > > > > <SELECT id="Select1" style="Z-INDEX: 101; LEFT: 159px; POSITION:
    > > > > > > > absolute; TOP: 382px" name="ddlist">
    > > > > > > > <OPTION selected></OPTION>
    > > > > > > > </SELECT>
    > > > > > > > </form>
    > > > > > > > </body>
    > > > > > > > </HTML>
    > > > > > > >
    > > > > > > > --------------------------------------------------------------------------------------------
    > > > > > > > "J.W." wrote:
    > > > > > > >
    > > > > > > > > Mm....don't recall there is a add function of a selectbox.......
    > > > > > > > >
    > > > > > > > > Maybe try this:
    > > > > > > > >
    > > > > > > > > var opt = new Option(text,value,defaultSelected,selected);
    > > > > > > > > selectboxObj.options[selectboxObj.options.length] = opt;
    > > > > > > > >
    > > > > > > > > might help............
    > > > > > > > >
    > > > > > > > >
    > > > > > > > > "deepak kumar" wrote:
    > > > > > > > >
    > > > > > > > > > i want to populate dropdownlist(integer values)(0,1,.....29) on client side
    > > > > > > > > > using javascript ...i m confused becoz ERROR IS: ->"OBJECT EXPECTED" .. i
    > > > > > > > > > want that when poge loads then dropdownlist should be populate at client side
    > > > > > > > > > automatically...
    > > > > > > > > >
    > > > > > > > > > ---------------------------------------------------------------------------------------------
    > > > > > > > > > <script language="javascript">
    > > > > > > > > > function fnPopulate()
    > > > > > > > > > {
    > > > > > > > > > for(int i=0;i<=29;i++)
    > > > > > > > > > {
    > > > > > > > > > var myValue=document.createElement("<option value='" + i + "'>" + i +
    > > > > > > > > > "</option>");
    > > > > > > > > > document.Form1.ddlist1.add(myValue);
    > > > > > > > > > }
    > > > > > > > > >
    > > > > > > > > > }
    > > > > > > > > > }
    > > > > > > > > >
    > > > > > > > > > </script>
    > > > > > > > > > --------------------------------------------------------------------------------------------
    deepak kumar, Nov 5, 2004
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jensen bredal
    Replies:
    2
    Views:
    6,143
    Eliyahu Goldin
    Oct 6, 2005
  2. Matcon
    Replies:
    3
    Views:
    21,511
    Matcon
    May 28, 2008
  3. deepak kumar
    Replies:
    0
    Views:
    129
    deepak kumar
    Oct 29, 2004
  4. Mohsen Pahlevanzadeh
    Replies:
    0
    Views:
    107
    Mohsen Pahlevanzadeh
    Sep 9, 2013
  5. MRAB
    Replies:
    0
    Views:
    107
Loading...

Share This Page