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

Getting the value of a textbox without submitting the form 2

Status
Not open for further replies.

princessk1

Programmer
Feb 28, 2002
74
CA
I am trying to change the value of one textbox on my ASP page when the values of the other textbox are changed by the user. Is it possible to get the value of a textbox on the page without submitting the form?
 
Yes, you do that in javascipt in the HTML on the client, not in the ASP script.

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>

<html>
<head>
	<title>You say Yes, I say No</title>
</head>

<body>
<form name=&quot;answers&quot;>

What is?<input type=&quot;text&quot; name=&quot;assertion&quot; value=&quot;A&quot; onchange=&quot;deny()&quot;>
<br>
What is not.<input type=&quot;text&quot; name=&quot;denial&quot; value=&quot;A is not A&quot;>

</form>

<script>
function deny(){
	var fieldOne = document.answers.assertion.value;
	
	var fieldTwo = fieldOne + &quot; is not &quot; + fieldOne;
	
	document.answers.denial.value = fieldTwo;
}
</script>

</body>
</html>
 
Thanks - When I run yours it works fine but when I try to incorporate the idea into my code I get an error:

I wrote...
val = document.Percent.textbox1.value
document.percent.total.value = val

and get the error....
Object doesn't support this object or method
document.Percent.textbox1.value

Percent is the name of the form
textbox1 is the name of the textbox
total is the name of the textbox I want val to show up in

Do you know why this would be?
 
if u are using JScript i think that u need to write the corect name of the object cuz JS is case sensitive...
<b><code>
<form name=Percent id=Percent>
<input name=textbox1 id=textbox1>
<input name=total id=total>
</form>
<script language=javascript>
var val = document.Percent.textbox1.value
document.Percent.total.value = val
</script>
</code>
</b>

hope this helps, if not plese post your code ________
George, M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top