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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update text field based on value in another text field

Status
Not open for further replies.

optjco

IS-IT--Management
Apr 13, 2004
185
GB
Can I update the value in a textfield by checking the value in another field. I have the code below but I get an internal error message when i try to run the page

Code:
<%
txtCause=Request.Form("txtCause")
txtStatus=Request.Form("txtStatus") 
	If txtCause.value > 0 Then
	txtStatus = "Pending"
	Else
	txtStatus = "Outstanding"
	%>
	<%
	End If
  End If
%>

Regards

Olly
 
Genimuse,
changed my code to this
Code:
<%
TCause=Request.Form("txtCause")
TStatus=Request.Form("txtStatus") 
    If TCause.value >0 Then
    TStatus = "Pending"
    Else
    TStatus = "Outstanding"
    End If
%>

Now i get

Microsoft VBScript runtime error '800a01a8'

Object required: '[string: "TCause"]'

/NC/Pending.asp, line 56

Any ideas please


Regards

Olly
 
Yes, TCause is just a variable, not an object, so it has no properties (.value would be a property). Instead just put If TCause > 0 Then
 
Thanks for that, just one other question if you don't mind

I have set the value of txtStatus to
Code:
<%=TStatus%>

which is fine when I load the form but how can i refresh the field after I have added text to the other 2 fields ??
so that txtStatus shows the new value

Regards

Olly
 
You could use Javascript on the client-side to move the value(s) rather then processing it server-side with ASP. Maybe use the onChange event or onKeyUp event on your initial box to feed the value to your secondary input, something like:
Code:
<input type="text" name="txtBox1" onChange="document.getElementsByName('txtBox2')[0].value=this.value;">
<input type="text" name="txtBox2">

or

<input type="text" name="txtBox1" onKeyUp="document.getElementsByName('txtBox2')[0].value=this.value;">
<input type="text" name="txtBox2">

or something like that.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top