...

View Full Version : Extracting Values from a dynamically created row.



sudhasundaram
06-19-2007, 12:57 PM
I have created a table and using the table id, I have created rows dynamically using the id of the table. I have also inserted cells and added values to that. Now I have to extract the values individually and add it to a textbox and edit it and I have to save it in the same cell from where I have brought the value.

I need to do these using Javascript. It's working fine if there is only one row. But I need to create multiple rows and the last 2 cells of each row contains an "Edit" and a "Delete" button. If I click the particular "Edit" or "Delete" button that values should be brought to the text boxes and edited and saved back.

Thanks in Advance.............
Can anyone please reply. It would be so helpful.

A1ien51
06-19-2007, 02:17 PM
Helped if you showed us code!

Give each row an id and reference that id with the button click.

Eric

sudhasundaram
06-19-2007, 04:19 PM
<html>
<body>
<script>
var variable1,variable2;
function show(id)
{
var itm=document.getElementById(id);
if(itm.style.display == 'none')
itm.style.display ='';
}


function addrow(fname,emailid)
{
if(fname.value !="" && emailid.value != "")
variable1=fname.value;
variable2=emailid.value;
t1.innerHTML="\""+variable1+"\""+"&lt"+variable2+"&gt"+"&nbsp;&nbsp;&nbsp;&nbsp;"+"<input type=button name=edit value=Edit onclick='validateedit()'>"+"&nbsp;&nbsp;&nbsp;&nbsp;"+"<input type=button name=delete value=delete onclick='validatedelete()'>";
fname.value="";
emailid.value="";
frm.add.value="add";
}
function validateedit()
{
frm.fullname.value=variable1;
frm.email.value=variable2;
frm.add.value="Edit";
t1.innerHTML="";
}
function validatedelete()
{
t1.innerHTML="";
}
</script>
<form name="frm">
<div id="t1" style="display:none">
</div>
Fullname<input type="text" name="fullname"><br>
EmailAddress<input type="text" name="email"><br>
<input type="button" value="add" name="add" onclick="show('t1'),addrow(this.form.fullname,this.form.email)">
</form>
</body>
</html>



This works fine for 1 row. But each row created that particular values should be edited and updated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum