Tip

Delete A Row

Suppose a table contains 15 rows and each row contains 4 fields named
A1,B1,C1,D1 for the first row,A2,B2,C2,D2 for the second row,A15,B15,C15,D15
and so on.Suppose you want to delete all the fields in a row by cliking any of
the fields in the row.All the rows beneath the deleted one wil be moved up one
step.ie,if the deleted row is fifth one,sixth row become fifth,seventh row
become sixth and so on.
Call a function "findline(name)"in the onFocus event of all the fields in all
the rows.
Call a function "deletei()" in the onclick event of action button.Then write
the following code in the JSHeader event of the form.This works both in web and
notes.Similarly you can make inserting a row.
var lastdigit =0;
function findline(fieldname) // Function Used to Find out the Field name for
the currect cursor position//
{
var len;
var ev;
len=fieldname.length;
lastdigit=fieldname.charAt(len-1);
pre = fieldname.charAt(len-2);
if (pre =="1")
{
lastdigit=pre+lastdigit;
}
lastdigit=eval(lastdigit);
}

//function for delete button
// this function is used to delete a row from the requested item list//
function deletei()
{

var incre;

for(var i=lastdigit;i&LT15i++)
{
incre=i+1

document.forms[0]["A"+i].value=document.forms[0]["A"+incre].value;
document.forms[0]["B"+i].value=document.forms[0]["B"+incre].value;
document.forms[0]["C"+i].value=document.forms[0]["C"+incre].value;
document.forms[0]["D"+i].value=document.forms[0]["D"+incre].value;

}
document.forms[0]["A"+15].value="";
document.forms[0]["B"+15].value="";
document.forms[0]["C"+15].value="";
document.forms[0]["D"+15].value="";

alert("One row of fields has been removed");
lastdigit =0
}

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.