I’m using visual studio 2008 with Rad controls Q3.
My main question is: How do I set the value/text of a numerica text box in javascript code?
I’m using Visual Studio 2008 with Q3. I have a master page with numerous content pages. On one page i have a few numeric textboxes. I have been able to grab the values of the textboxes and do any calculations with them that I need, but I have not been able to write my values into another textbox. How do I do this? Here’s all my code for this so far.
(Masterpage)
[code=html]<%@ Master Language=”VB” CodeFile=”MasterPage.master.vb” Inherits=”MasterPage” %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title>Untitled Page</title>
<asp:ContentPlaceHolder id=”head” runat=”server”>
</asp:ContentPlaceHolder>
</head>
<body bgcolor=”#cccccc”>
<form id=”form1″ runat=”server”>
<div>
<script type=”text/javascript”>
function TestCalc(te, ca, db)
{
alert(“Calculating”);
var totalExpenses = document.getElementById(te).value;
var cashAdvance = document.getElementById(ca).value;
var directBillings = document.getElementById(db).value;
var due = (totalExpenses – cashAdvance – directBillings);
//cashAdvance.SetValue(directBillings);
//cashAdvance.innerHTML = 0;
//ca.innerHTML = 0;
//document.getElementById(ca).innerHTML = “0”;
// if (due < 0)
// {
// var DueAmount = (due * (-1));
// var DueEmployer = document.getElementById(der);
// alert(DueEmployer.value);
// DueEmployer.Value = DueAmount;
// alert(DueEmployer.value);
//
// }
// else{
// var DueAmount = due;
// var DueEmployee = document.getElementById(dee).value;
// dee.SetValue(DueAmount);
// }
}
</script>
<asp:ContentPlaceHolder id=”ContentPlaceHolder1″ runat=”server”>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Default.aspx
[CODE]Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
RadNumericTextBox1.Attributes.Add(“onBlur”, “TestCalc(‘” & RadNumericTextBox1.ClientID & “‘, ‘” & RadNumericTextBox2.ClientID & “‘, ‘” & RadNumericTextBox3.ClientID & “‘)”)
End Sub
[code=html]<%@ Page Language=”VB” MasterPageFile=”~/MasterPage.master” AutoEventWireup=”false” CodeFile=”Default.aspx.vb” Inherits=”_Default” title=”Untitled Page” %>
<%@ Register assembly=”RadInput.Net2″ namespace=”Telerik.WebControls” tagprefix=”rad” %>
<asp:Content ID=”Content1″ ContentPlaceHolderID=”head” Runat=”Server”>
</asp:Content>
<asp:Content ID=”Content2″ ContentPlaceHolderID=”ContentPlaceHolder1″ Runat=”Server”>
<p>
<br />
<table style=”width: 27%;”>
<tr>
<td>
<rad:RadNumericTextBox ID=”RadNumericTextBox1″ Runat=”server”>
</rad:RadNumericTextBox>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<rad:RadNumericTextBox ID=”RadNumericTextBox2″ Runat=”server”>
</rad:RadNumericTextBox>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<rad:RadNumericTextBox ID=”RadNumericTextBox3″ Runat=”server”>
</rad:RadNumericTextBox>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</p>
</asp:Content>
Any help would be greatly appreciated. Please let me know if more information is needed. Thanks!