Solved

document.form.textarea.value

Posted on 2003-10-29
9
1,267 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

717 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