Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

document.form.textarea.value

Posted on 2003-10-29
9
1,260 Views
Last Modified: 2011-10-03
Hi

I have a function which takes id as parameter.My table has n number of rows, each row has textarea with name as txtIssuen.........where n increases as I add row...so textarea name becomes like txtIssue1,txtIssue2....so on...Now whenever button in the row is clicked ..corresponding textarea value has to become empty(value="")..so onClick of button I am calling JavaScript function which is show below.

function fun(id)
{
    document.formname.txtIssue+id.value = "";
}

When I run the above function I get error...How do I add id to the txtIssue..so that it beomes like
document.frmWeeklyReport.txtIssue1.value = ""; or
document.frmWeeklyReport.txtIssue2.value = "";

depending on id value...

Your help is appreciated

Rgds
Surjit
0
Comment
Question by:sursatraj
  • 5
  • 2
9 Comments
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9640977
sursatraj,
Try this :
<script>
function fun(textAreaName,total)
{
   var i
   for(i=1;i<=total;i++)
  {
     document.getElementById(textAreaName+i).value = "";
   }
}
</script>

<input type="button" value="Clear All TextArea" onClick="javascript:fun('txtIssue','4')">

Regards
x_com
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 70 total points
ID: 9640986
My previous solutions is clear all textarea. Here, clear textarea based on selected row.
If you want to clear 1 textarea accordingly the related button(row), try this :
<script>
function fun(textAreaName,id)
{
    document.getElementById(textAreaName+id).value = "";
}
</script>

<input type="button" value="Clear" onClick="javascript:fun('txtIssue','1')"> <-----first row

 
0
 
LVL 28

Expert Comment

by:sybe
ID: 9641043
function fun(id)
{
    eval('document.formname.txtIssue'+id+'.value = ""');
}

0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:sursatraj
ID: 9641055
Hi,

That was Perfect Answer.I got it....

Thanks & Rgds,
Surjit
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9656528
sursatraj,
Why gred B? Perfet answer not rewarded with gred "A"?
Please refer :
http://www.experts-exchange.com/help/mistakes.jsp#2
0
 

Author Comment

by:sursatraj
ID: 9656617
Hi X-com,

I am very sorry for that.It was my mistake.In a hurry I have selected that option.I won't repeat next time

Perfect Answer = "A"

Rgds
Surjit
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9658827
sursatraj ,
So,i'll request admin to change the grade to "A".

Regards
x_com
0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 9661863
Thanks for your assistance, Lunchy.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question