选择下拉列表项时添加行

时间:2012-08-13 17:39:54

标签: javascript jquery asp.net drop-down-menu

enter image description here

我的数据行名为模块,优先级,请求日期等,这些行是在我的网站上动态获取的。当从我的下拉列表中选择计算机请求的值时,有没有办法在名为“cost center”的模块下添加一行? 这是下拉列表的代码。

    <span id="dg_form_ctl02_lbl_show_tag" style="display:inline-block;background-    color:Transparent;border-color:Navy;border-width:3px;border-style:Double;font-    family:Arial;font-size:12px;width:130px;">Module*</span> 
                                                </td><td>








                                                    <select name="dg_form$ctl02$DropDownList1" onchange="javascript:setTimeout('__doPostBack(\'dg_form$ctl02$DropDownList1\',\'\')', 0)" id="dg_form_ctl02_DropDownList1">
        <option value="">--select one--</option>
        <option value="Cellular Phone">Cellular Phone Request</option>
        <option selected="selected" value="Computer">Computer Request (Up to VP Approval)</option>
        <option value="Account Creation">Create Network/SAP Account</option>
        <option value="Account Delete">Delete Network/SAP Account</option>
        <option value="FIS">FIS</option>
        <option value="FP">FP</option>
        <option value="General">General Support</option>
        <option value="Report">Reports</option>
        <option value="SAP">SAP</option>
        <option value="Web Application">Web Application</option>

    </select>





                                                </td>
</tr><tr style="background-color:White;">
    <td valign="top">

这是我目前为警报所用的代码

function alertMe() {
var n = document.getElementById("dg_form_ctl02_DropDownList1").value;
if (n == "Computer") {
alert ('Changed');

1 个答案:

答案 0 :(得分:0)

我认为这会有用

selectObject.add(option,before)


function GetSelectedValue(selectItem)
{
var index = document.getElementById(selectItem).selectedIndex;

alert("value =" + document.getElementById(selectItem).value);
alert("text =" + document.getElementById(selectItem).options[index].text);
}



<select id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>