/    Sign up×
Community /Pin to ProfileBookmark

Value won’t show up

Hi I’m really new at javascript and need some help. When i view the following code in Netscapes javascript console, I get an error that says
the text area I want to print to is not defined but i gave the text area a name. Don’t know what’s wrong so if someone could help me out, I would greatly appreciate it. Here’s the code:

[COLOR=coral]

<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
<script language=”javascript”>
function myFunct(form1,texta){
var word=form1.enstring.value;
}
form2.texta.value=word;
</script>
</head>

<body align=”center”>
<form name = “form1”>
<div align=”center”>
<input name=”enstring” type=”text” value=”” size=”100″>
<input type=”button” value=”Run Program”
name=”start” onclick=”myFunct(document.form1,document.form2.texta);”>
</div>
</form>

<form name=”form2″>
<p align=”center”><textarea rows=”17″ name=”texta” cols=”38″></textarea></p>
</form>
</body>
</html>

[/COLOR]

Thanks.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterFeb 21.2005 — Your function has been cut short.

Try:
<i>
</i>function myFunct(form1,texta){
var word=form1.enstring.value;
texta.value=word;
[color=red]}[/color]
Copy linkTweet thisAlerts:
@UltimaterFeb 21.2005 — Next, if your aiming at Compatibility:
<i>
</i>function myFunct(){

if(document.forms){
var word=document.forms["form1"].enstring.value;
document.forms["form2"].texta.value=word;
return true
}

if(document.getElementsByName){
var word=document.getElementsByName("enstring")[0].value;
document.getElementsByName("texta")[0].value=word;
return true
}

if(document.form1.enstring){
var word=document.form1.enstring.value;
document.form2.texta.value=word;
return true
}

return true
}
Copy linkTweet thisAlerts:
@Warren86Feb 21.2005 — <HTML>

<Head>

<Script Language=JavaScript>

function myFunct(isWord,isXferField){

isXferField.value = isWord;
}


</Script>

</Head>

<Body>

<div align="center">

<form name = "form1">

<input name="enstring" type="text" value="" size="100">

<input type="button" value="Run Program"

name="start" onclick="myFunct(this.form.enstring.value,document.forms.form2.texta);">

</form>

<form name="form2">

<textarea rows="17" name="texta" cols="38"></textarea>

</form>

</div>

</Body>

</HTML>
×

Success!

Help @Bad_Oscar 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.16,
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,
)...