Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript not updating textbox

Status
Not open for further replies.

JoDaCoda

Programmer
Dec 11, 2003
18
US
I have an asp.net webform, which uses a javascript function to update a textbox with a value from a dropdownlist. This same code works fine on my other forms, but this one nothing happens. I have commented out all the code with the exception of sending a test string back to the textbox. This doesn't even work. If I take out the comment marks in the javascript function, the alert box shows the correct value, so I know the function is firing.

[green]javascript.js:[/green]
function SetCertFee()
{
//var ind = document.Form1.ddlDescr.selectedIndex;
//var ddlVal = document.Form1.ddlDescr(ind).value;
//alert(ddlVal);
[red]document.Form1.txtCertFee.text = "test";[/red]
}

[green]asp.net webform.aspx.vb:[/green]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
AddHandler EditMenu1.Cancel_OnClick, AddressOf CancelClicked
AddHandler EditMenu1.Save_OnClick, AddressOf SaveClicked
AddHandler EditMenu1.New_OnClick, AddressOf NewTransaction

menu1.SetMenuView(Session("Usr.SecurityLevel"))
EditMenu1.SetEditMenuView(Session("Usr.SecurityLevel"))
menu1.CurrentForm("btnTransaction")

If Not IsPostBack Then
dgSelectedItem = -1
GetListData()
End If
If Not IsNothing(Request.QueryString("Mode")) Then
Select Case Request.QueryString("Mode")
Case "New"
NewTransaction(Me, e)
Case "Edit"
EditTransaction(Me, e)
Case "View"
ViewTransaction()
End Select
End If

txtTranDate.Attributes.Add("onchange", "FormatDate('txtTranDate');")
txtPmtDate.Attributes.Add("onchange", "FormatDate('txtPmtDate');")
txtSecNotice.Attributes.Add("onchange", "FormatDate('txtSecNotice');")
txtFinalNotice.Attributes.Add("onchange", "FormatDate('txtFinalNotice');")
[red]ddlDescr.Attributes.Add("onchange", "SetCertFee();")[/red]


End Sub


[green]asp.net webform.aspx:[/green]
<%@ Register TagPrefix="uc1" TagName="currentuser" Src="ctlCurrentUser.ascx" %>
<%@ Register TagPrefix="uc1" TagName="menu" Src="ctlMenu.ascx" %>
<%@ Register TagPrefix="uc1" TagName="header" Src="ctlHeader.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctlEditMenu" Src="ctlEditMenu.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="wfrmTransactionEdit.aspx.vb" Inherits="bsims.wfrmTransactionEdit" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Some Title</title>
<meta content="False" name="vs_snapToGrid">
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content=" name="vs_targetSchema">
<LINK href="StyleSheet.css" type="text/css" rel="stylesheet">
[red]<script language="javascript" src="javascript.js"></script>[/red]
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:textbox id="txtCertFee" style="Z-INDEX: 149; LEFT: 115px; POSITION: absolute; TOP: 197px"
runat="server" Font-Size="XX-Small" Font-Names="arial" Width="74" Height="20px"></asp:textbox>
</form>
 
That worked! Thanks. Do you have any idea why .text property works on my other pages but not this one?
 
No idea, I always use .value when using javascript...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top