[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

document.form.textarea.value

Posted on 2003-10-29
9
Medium Priority
?
1,292 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
8 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 280 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
Industry Leaders: 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
Suggested Courses

872 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