/    Sign up×
Community /Pin to ProfileBookmark

What’s wrong in my code!?

Hi all, I have a page which contains: Form called F1 –> Textbox called T1 and Textarea called A1..

When I click on a button it takes the value of T1 and then do it like this..

if the value is java then it should out put:

j
ja
jav
java

on the textarea..

I have the following code which is not working:

[CODE]function show()
{
var a = F1.T1.value;
var i = 0;
while ( i <= a.length )
{
i = i + 1;
F1.A1.value = a.substring(0,i);
}
}[/CODE]

also how can I print more than 1 line in the textarea..

Thanks in advance,
zeid

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorDec 05.2006 — <i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;meta http-equiv="Content-Script-Type" content="text/javascript"&gt;
&lt;script type="text/javascript"&gt;
function writeT(f){
var v=f['T1'].value;
var i=1, t='';
while(i&lt;=v.length){
t+=v.substring(0,i)+'n';
i++;
}
t=t.replace(/n$/,'');
f['A1'].value=t;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form&gt;
&lt;input type="text" name="T1"&gt;
&amp;nbsp;
&lt;input type="button" value="Write" onclick="writeT(this.form)"&gt;
&amp;nbsp;
&lt;textarea name="A1" rows="4"&gt;&lt;/textarea&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@zeidauthorDec 05.2006 — thank you very much ?
×

Success!

Help @zeid spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...