/    Sign up×
Community /Pin to ProfileBookmark

please help very urgent…

i am supposed to create a row(<tr>) of 3 textboxes and will set the events and other required attributes on those textboxes.

i’ll keep these textboxes row as a single object.

now in a table which ever row i’ll click the row should be replaced by the textbox’s row which i created earlier.

please help me!!!!!

thanking you

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@saju_mauthorJan 30.2003 — hi,

sorry for the disturbance.

pls help.

here by i'm attaching a javascript which i created as u said but not using innerHTML but using createElement(created textboxes),

but like that can u help me in creating a whole row( i mean row of 3 cells with one textbox each) using createElement(i'll create it only once). so that when i click on a row of a table that row should be replaced by the row object which i kept created already.

---------------------javascript------------------

<HTML>

<HEAD>

<SCRIPT>

var st=-1;

var tblOldCells = new Array(10);

function createText()

{

if(st!=-1)
{
var tblCells = document.getElementById("tid").rows[st].cells;
var j, len = tblCells.length;
for (j=0; j<len; j++)
{
tblCells[j].innerText = tblOldCells[j];
}
st = -1;
}

var t = event.srcElement;

st = t.parentElement.rowIndex;
var tblCells = document.getElementById("tid").rows[t.parentElement.rowIndex].cells;



var j, len = tblCells.length;


for (j=0; j<len; j++)
{

var oNewItem = document.createElement("input");
oNewItem.value=tblCells[j].innerText;
tblCells[j].innerText="";
tblCells[j].insertBefore(oNewItem);
tblOldCells[j] = oNewItem.value;
}


}
</SCRIPT>
</HEAD>
<BODY >
<table id="tid" border = "1" >
<tr onclick="createText()">
<td id="td1">Italy</td>
<td id="td2">UK</td>
<td id="td3">Spain</td>

</tr>
<tr onclick="createText()">
<td id="td4">USA</td>
<td id="td5" >Canada</td>
<td id="td6" >Mexico</td>

</tr>
<tr onclick="createText()">
<td id="td4">India</td>
<td id="td5" >China</td>
<td id="td6" >Japan</td>
<td id="td6" >Korea</td>
</tr>
</table>

<BODY>

</HTML>
×

Success!

Help @saju_m spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...