0

I'm trying to pass and convert two asp.net TextBoxes to a JavaScript Float.

This is my JavaScript code:

var Jvar1 = parseFloat(getElementById("<%= LogTextBox.ClientID %>").value);
var Jvar2 = parseFloat(getElementById("<%= LatTextBox.ClientID %>").value);

This my Asp.net code:

<asp:Table ID="tbsiteinfo" runat="server">

<asp:TableRow>
<asp:TableCell HorizontalAlign="left" CssClass="paddingLeftRight5px"  >
<asp:Label ID="Label26" runat="server" Width="220px" Text="Lat"></asp:Label>
</asp:TableCell>
<asp:TableCell HorizontalAlign="left" CssClass="paddingLeftRight5px" >
<asp:TextBox Width="200px" ID="LatTextBox" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign="left" CssClass="paddingLeftRight5px"  >
<asp:Label ID="Label27" runat="server" Width="220px" Text="Log"></asp:Label>
</asp:TableCell>
<asp:TableCell HorizontalAlign="left" CssClass="paddingLeftRight5px" >
<asp:TextBox Width="200px" ID="LogTextBox" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>

</asp:Table>

For some reason the values are not coming up at all. Any ideas? thanks so much for the help.

1
  • It should be document.getElementById. Commented Oct 24, 2013 at 20:37

1 Answer 1

1

getElementById is the function of document object, so you need to use it like document.getElementById('id'). So your syntax would be.

var Jvar1 = parseFloat(document.getElementById("<%= LogTextBox.ClientID %>").value);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.