|
-
Jul 12th, 2004, 01:05 PM
#1
Thread Starter
Addicted Member
updating textbox in javascript problem - simple question
hi all
i wrote the folowing javascript code
<html>
<head>
<script language ="javascript">
function Change()
{
document.test1.tbText1.value = 20
}
</script>
<body>
<form name="test1" method="post" onsubmit ="Change()">
<input type="text" name="tbText1">
<br>
<input type="submit" value="submit">
</form>
when i press on the submit button i cant see value 20 in the textbox
1. why does it happen?
2. as a result how do i cange in the same way checkbox??
thanks alot
Ron
-
Jul 12th, 2004, 01:09 PM
#2
Thread Starter
Addicted Member
continuing
by the way my aim is to populate form with array (by loop) by clicking submit button
-
Jul 12th, 2004, 01:26 PM
#3
Thread Starter
Addicted Member
continuing
by the way my aim is to populate form with array (by loop) by clicking submit button
-
Jul 12th, 2004, 05:27 PM
#4
Stuck in the 80s
Code:
<html>
<head>
<script language ="javascript">
function Change()
{
document.test1.tbText1.value = 20
return false;
}
</script>
<body>
<form name="test1" method="post" onsubmit ="return Change()">
<input type="text" name="tbText1">
<br>
<input type="submit" value="submit">
</form>
The reason why you can't see the value is because the form is submitting (in this case, reloading the page).
Another method for this would be:
Code:
<html>
<head>
<script language ="javascript">
function Change()
{
document.test1.tbText1.value = 20
}
</script>
<body>
<form name="test1" method="post">
<input type="text" name="tbText1">
<br>
<input type="button" value="submit" onclick="Change()">
</form>
-
Jul 13th, 2004, 11:48 AM
#5
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|