• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1298
  • Last Modified:

document.form.textarea.value

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
sursatraj
Asked:
sursatraj
  • 5
  • 2
1 Solution
 
David H.H.LeeCommented:
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
 
David H.H.LeeCommented:
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
 
sybeCommented:
function fun(id)
{
    eval('document.formname.txtIssue'+id+'.value = ""');
}

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
sursatrajAuthor Commented:
Hi,

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

Thanks & Rgds,
Surjit
0
 
David H.H.LeeCommented:
sursatraj,
Why gred B? Perfet answer not rewarded with gred "A"?
Please refer :
http://www.experts-exchange.com/help/mistakes.jsp#2
0
 
sursatrajAuthor Commented:
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
 
David H.H.LeeCommented:
sursatraj ,
So,i'll request admin to change the grade to "A".

Regards
x_com
0
 
David H.H.LeeCommented:
Thanks for your assistance, Lunchy.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now