/    Sign up×
Community /Pin to ProfileBookmark

Add or delete rows from a table

Hello
I am have 20 rows showing on a table…
If the user wants more places for inputs I want them to be able to click “Add a User” link that will add more rows…
Any help would greatly appreciated!
I have some code I found but it is only good for one row and they need the option of adding multiple rows.
<script>
function toggle() {
if( document.getElementById(“hidethis”).style.display==’none’ ){
document.getElementById(“hidethis”).style.display = ”;
}else{
document.getElementById(“hidethis”).style.display = ‘none’;
}
}
</script>
<tr><td colspan=”3″ align=”center”><a onClick=”toggle();”>toggle</a></td></tr>

<tr id=”hidethis”><td>Player Name</td><td><input type=”text” name=”player21f”></td><td><input type=”text” name=”player21l”></td></tr>

Appreciate any help I can get!
Thanks!
J

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@PETTEJul 12.2010 — I've never used this kind of scripting below, I mean I've never tested how that works out.

[code=html]function toggle() {
if( document.getElementById("hidethis").style.display=='none' ){
document.getElementById("hidethis").style.display = '';
}else{
document.getElementById("hidethis").style.display = 'none';
}[/code]



The script above is just hiding and unhiding the element, it's not adding more rows. You'll need to use the Node Object Methods. One in particular appendChild(newChild). Calling the element by id and appending more elements/children
Copy linkTweet thisAlerts:
@jbradley04authorJul 12.2010 — Sorry to be so needy but I do not understand...

You have an example how this can woprk? Or you have a link that I can check out to see how it works...

I am not sure about javascript!

I want to get an entire <tr></tr> of html in the hidden field and when clicked it would add more rows from the html form!

Thanks!

J
×

Success!

Help @jbradley04 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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