Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

document.form.textarea.value

Posted on 2003-10-29
9
Medium Priority
?
1,283 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

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!

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

609 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