views:

33

answers:

2

Hello,

I need to call a functoin on button click and pass the value of id into that function...here is what I m doing ...but I bet i m doing sth wrong bcoz its not working

function Datarate(frm) {

    var ar = document.getElementById('<%= submit.ClientID%>');
    alert(ar);
}

<asp:Button runat="server" ID="submit" Text="Submit" OnClientClick="return Datarate(this.form);" PostBackUrl="www.google.com" /> 

but i m getting alert as null...

any idea where I m getting wrong... Thanks,

A: 

try to see sources of rendered page in browser, i am pretty sure you will understand the problem

Andrey
+1  A: 
var ar = document.getElementById('<%= submit.ClientID%>').value;
alert(ar);

Try adding .value

RandomNoob
I tried this and its showing document.getElementById('<%= submit.ClientID%>') is null
AB