469,343 Members | 5,380 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

dynamic acess of objects problem

i am creating a page that creates 10-45 text input areas dynamically in a
for loop. all the fields will be identical except for content, and i need a
button to clear each corresponding field individually(also dynamically
created). i have tried to do it various ways, but i cant get the proper
object declared, i always get object does not exist or object undefined
errors. I dont even know what this is called so that i can look it up. im
kind of lost as how to solve it.

below is my code

<script language="JavaScript">
<!--
// num is the number corresponding to the appropiate textarea
// function makeblank(num)
{
titlenum='txt' + num.toString();
var txt = document.form1.txtnum;
txt.value="";
}
//-->
</script>

<html>
<form name="form1" action="/admin/feedback.php" method="post">

<textarea name="txt1" style="width: 600px; height: 200px"></textarea>
<textarea name="txt2" style="width: 600px; height: 200px"></textarea>
<textarea name="txt3" style="width: 600px; height: 200px"></textarea>

</form>
</html>
Jul 20 '05 #1
2 1475
"Brad Esclavon" <gt*****@mail.gatech.edu> writes:
i am creating a page that creates 10-45 text input areas dynamically in a
for loop. all the fields will be identical except for content, and i need a
button to clear each corresponding field individually(also dynamically
created). i have tried to do it various ways, but i cant get the proper
object declared, i always get object does not exist or object undefined
errors. I dont even know what this is called so that i can look it up. im
kind of lost as how to solve it.

below is my code <script language="JavaScript">
It's
<script type="text/javascript">
in HTML 4 and later.
<!--
You don't need HTML comments in Javascript.
// num is the number corresponding to the appropiate textarea
// function makeblank(num)
This line shouldn't be commented out?
{
titlenum='txt' + num.toString();
var txt = document.form1.txtnum;
Is it "titlenum" or "txtnum"?
txt.value="";
}
//-->
</script>


What you probably need is:
---
<script type="text/javascript">
function makeblank(num)
{
document.forms['form1'].elements['txt'+num].value="";
}
</script>
---
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
DU
Brad Esclavon wrote:


<html>
<form name="form1" action="/admin/feedback.php" method="post">

<textarea name="txt1" style="width: 600px; height: 200px"></textarea>


I just wanted to add this to Lasse's excellent post.

rows and cols are required attributes in HTML 4 and in all other HTML
versions. These attributes are mandatory as they help browsers figure
out when/where to wrap text lines.
http://www.w3.org/TR/REC-html32#textarea
http://www.w3.org/TR/html401/interac...#edef-TEXTAREA
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Nathan Bloomfield | last post: by
3 posts views Thread by Stephen Gennard | last post: by
9 posts views Thread by wASP | last post: by
3 posts views Thread by NateDawg | last post: by
reply views Thread by Pascal Costanza | last post: by
3 posts views Thread by cwertman | last post: by
11 posts views Thread by toton | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.