2015-06-22 52 views
-3

我正在編輯一個ascx,其中有一個單選按鈕的模式彈出窗口。 當無線電值發生變化時我想調用JavaScript函數,但該函數不起作用。下面是代碼:無法調用單選按鈕值更改的JavaScript函數

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"> 
</script> 

<script> 
function UcSelect() { 
    var value = $("#<%= rbtTipo.ClientID %> :checked").val(); 
    if (value == 'E') { 
     alert("aaaaaaaaaaaaa"); 
    } 
    if (value == 'G') { 
     alert("bbbbbbbbbbbbbbbbbb"); 
    } 
    return true; 
} 
</script> 

,並在彈出裏面的按鈕:

<asp:RadioButtonList ID="rbtTipo" runat="server" Style="margin-top: 4px; margin-bottom: 8px;" onclick="UcSelect();" > 
    <asp:ListItem Value="E">&nbsp; Nuovo Coefficiente Energia</asp:ListItem> 
    <asp:ListItem Value="G">&nbsp; Nuovo Coefficiente Gas</asp:ListItem> 
</asp:RadioButtonList> 

以在調試器一看,我發現這個消息:

Uncaught ReferenceError: UcSelect is not defined onclick @ CoefficientiPage.aspx:1

UPDATE:

相反,如果我把下面的代碼(修改)放在ascx其中包含彈出,我得到的警報Hello1,而且這個錯誤:GET http://ajax.go/ net::ERR_NAME_NOT_RESOLVED

<script> 
function UcSelect() { 
    alert('hello1'); 
    if ($("#rbtTipo :checked").val() == 'E') { 
     alert("aaaaaaaaaaaaa"); 
    } 
    return true; 
} 
</script> 

如何JS範圍的作品?我很困惑。

+2

你在哪裏給你的'