|
-
October 3rd, 2008, 06:17 PM
#1
what's wrong in this code?
Hi
I strucked with emails adding to the textarea. I used following code.
Code:
function addTo( emailAddr )
{
console.log('hi***'+document.emailForm.toAddr.value); // this prints empty but it goes to else block.
if ( document.emailForm.toAddr.value == ' ' )
document.emailForm.toAddr.value = emailAddr;
else
// document.emailForm.toAddr.value = emailAddr;
document.emailForm.toAddr.value += ', ' + emailAddr;
}
what's wrong in the above code.
Can any body give an Idea.
Thanks in advance...
-
October 6th, 2008, 07:11 AM
#2
Re: what's wrong in this code?
I used your code in the following page, and I see nothing wrong:
Code:
<html>
<head>
<script language=javascript>
function addTo(emailAddr)
{
// console.log('hi***'+document.emailForm.toAddr.value); // this prints empty but it goes to else block.
if ( document.emailForm.toAddr.value == ' ' )
document.emailForm.toAddr.value = emailAddr;
else
// document.emailForm.toAddr.value = emailAddr;
document.emailForm.toAddr.value += ', ' + emailAddr;
}
</script>
</head>
<body>
<form name="emailForm" id="emailForm">
<textarea name="toAddr" id= "toAddr" rows="5" cols="20">
One
Two
</textarea>
<input type="button" value="more" onclick="addTo('Three')">
</form>
</body>
</html>
-
October 15th, 2008, 10:16 AM
#3
Re: what's wrong in this code?
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
|