Adding item/s to a dropdownlist

Discussion in 'ASP .Net Web Controls' started by Anita C, Aug 23, 2003.

  1. Anita C

    Anita C Guest

    Hi,
    I have a dropdownlist on a webform amongst other controls. One of the items
    in the dropdownlist is 'New Value'. If the user selects 'New Value', I want
    a web form of a precise size and modal too, to help the user create a new
    value and when the new entry is accepted (in the modal webform) the new
    value is added to the dropdownlist. How do I achieve the above described ?
    Any help will be greatly appreciated .
     
    Anita C, Aug 23, 2003
    #1
    1. Advertising

  2. Anita C

    Rohit Guest

    Hi Anita,
    I hope this helps.

    //this function pops up a window where user can add a new item and on
    clicking OK
    the window is closed and the new item is added to the dropdownlist.

    function show()
    {
    var retValue = "";
    var aOp;
    var indx;
    var cmb = document.getElementById("cmbSelect");

    if(cmb.value != "0")
    return;

    var dialogOptions = "help:no; resizable:yes;
    dialogHeight:790px;dialogWidth:900px;";
    retValue = window.showModalDialog("WebForm3.aspx",null,dialogOptions);

    if(retValue != "")
    {
    aOp = document.createElement('OPTION');
    eval('aOp.innerText="' + retValue + '"');
    //Index is incremented by 1 for every new item added ,
    //You can change it as per your requirements
    indx = cmb.length+1;
    eval('aOp.value="' + indx + '"');
    cmb.insertBefore(aOp,cmb.item(indx-2));
    }
    }


    Regards,
    Rohit,


    "Anita C" <> wrote in message
    news:...
    > Hi,
    > I have a dropdownlist on a webform amongst other controls. One of the

    items
    > in the dropdownlist is 'New Value'. If the user selects 'New Value', I

    want
    > a web form of a precise size and modal too, to help the user create a new
    > value and when the new entry is accepted (in the modal webform) the new
    > value is added to the dropdownlist. How do I achieve the above described ?
    > Any help will be greatly appreciated .
    >
    >
     
    Rohit, Aug 27, 2003
    #2
    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. Chris
    Replies:
    2
    Views:
    1,784
    Chris Barrow
    Jul 22, 2003
  2. ssoss

    Display Related Item or Add Item

    ssoss, Sep 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    507
    ssoss
    Sep 19, 2003
  3. 00_CumPeeWearD12

    Adding background color to DropDownList's item?

    00_CumPeeWearD12, Feb 18, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,589
    00_CumPeeWearD12
    Feb 18, 2005
  4. =?Utf-8?B?Z2xlbm4=?=

    Adding dummy item to DropDownList in a DataGrid

    =?Utf-8?B?Z2xlbm4=?=, Apr 25, 2006, in forum: ASP .Net
    Replies:
    15
    Views:
    805
    Scott R
    May 8, 2006
  5. Replies:
    2
    Views:
    638
Loading...

Share This Page