Go Back   Gaming Gutter > Non-Gaming > Programming


Programming - All general programming discussion in here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Looking to buy 1-2...
Today 06:33 AM
Last post by Fewmitz again
Today 07:14 AM
7 Replies, 8 Views
Go to first new post Im Selling Roughly 76m...
Today 03:20 AM
by venture
Last post by ASHTEHCOMMIE
Today 07:12 AM
27 Replies, 28 Views
Go to first new post [PC]Account
Today 07:11 AM
by Kaze
Last post by Kaze
Today 07:11 AM
0 Replies, 1 Views
Go to first new post FIFA 08 fans in here!
07-22-2008 06:27 AM
Last post by venture
Today 07:11 AM
1 Replies, 2 Views
Go to first new post Sex before Marriage?
08-18-2008 04:15 AM
by mika
Last post by terinuptrash
Today 07:10 AM
42 Replies, 43 Views
Closed Thread
 
LinkBack Thread Tools Display Modes

 [javascript]need some help
Old 07-01-2008, 09:55 PM   #1 (permalink)
Underground
 
revolution's Avatar
 
revolution is offline
Join Date: Aug 2007
Location: Hiram, Georgia
Age: 19
Posts: 557
iTrader: 2 / 100%
revolution Is Recognizable
Rep Power: 4
[javascript]need some help

I'm looking for a pretty simple code. I can find codes to do the separate parts, but I can't manage to combine them to do what I need.

Contains the following:
1. A table
2. A textbox
3. Two buttons

What I want to be able to do is type something in the text box and click a button that says "Add Item". It then adds the input text to a cell in a row in the table and in the cell next to it, a button that says "Delete" that will delete that row, removing the item and its "Delete" button from the table. I'd like to be able to add as many items as I want.

EDIT

Also needs to be able to store the list so that you can update it later.
__________________
Trades Completed:
Yummy, Kismet, Konekokoi, xRuinationx





Last edited by revolution; 07-02-2008 at 07:35 AM.
 

 
Old 07-01-2008, 11:32 PM   #2 (permalink)
Underground
 
dyl1828's Avatar
 
dyl1828 is offline
Join Date: Feb 2007
Age: 15
Posts: 136
iTrader: 0 / 0%
dyl1828 Is gaining popularity
Rep Power: 5
Here you go,
Example: Example
Code:
<html>
<head>
<title>Test Page</title>
<script type="text/javascript">
function appendRow()
{
 var text= document.form.input.value;
 var button= '<input type="button" value="Delete" onclick="deleteRow(this.parentNode.parentNode.rowIndex)">'
 var tbody = document.getElementById("t1").getElementsByTagName("tbody")[0];
 var row = document.createElement("TR");
 var cell1 = document.createElement("TD");
 cell1.innerHTML = text;
 var cell2 = document.createElement("TD");
 cell2.innerHTML = button;
 row.appendChild(cell1);
 row.appendChild(cell2);
 tbody.appendChild(row);
}
function deleteRow(i){
    document.getElementById('t1').deleteRow(i)
}
</script>
</head>
<body>

<table id="t1" border="1">
<tbody>
</tbody>
</table>
<form name="form" id="form">
<textarea id="input" name="input"></textarea>
<input onclick="appendRow()" value="Add Item" type="button">
</form>

</body>
</html>
Hope you enjoy

P.S.
This code was tested and created on Firefox 2.0.0.14 with Javascript enabled
__________________
Trades Completed With Users On GG:
Dungeon_Master (gaiaonline<>neopets)

Last edited by dyl1828; 07-01-2008 at 11:33 PM. Reason: forget information
 

 
Old 07-02-2008, 06:18 AM   #3 (permalink)
Underground
 
revolution's Avatar
 
revolution is offline
Join Date: Aug 2007
Location: Hiram, Georgia
Age: 19
Posts: 557
iTrader: 2 / 100%
revolution Is Recognizable
Rep Power: 4
Exactly what I was looking for. Hadn't planned on using a textarea, but that's not a problem.

EDIT

I forgot one thing, I need it to not delete every time I refresh or go back to the page. I want it to be able to store so that every time I go back to it, the list is still there and I can sitll add items or delete the ones on there like normal.
__________________
Trades Completed:
Yummy, Kismet, Konekokoi, xRuinationx





Last edited by revolution; 07-02-2008 at 06:26 AM.
 

 
Old 07-02-2008, 09:34 AM   #4 (permalink)
Underground
 
dyl1828's Avatar
 
dyl1828 is offline
Join Date: Feb 2007
Age: 15
Posts: 136
iTrader: 0 / 0%
dyl1828 Is gaining popularity
Rep Power: 5
do you mind if it includes php in the script, because that is the only way i know how to do that.

Also without php you cant save the it because javascript is only client side (so you cant save to the server)

Edit:
Sorry, but i cant think or find a way to save the table. Sorry.
__________________
Trades Completed With Users On GG:
Dungeon_Master (gaiaonline<>neopets)

Last edited by dyl1828; 07-02-2008 at 10:50 AM.
 

 
Old 07-02-2008, 03:48 PM   #5 (permalink)
Underground
 
revolution's Avatar
 
revolution is offline
Join Date: Aug 2007
Location: Hiram, Georgia
Age: 19
Posts: 557
iTrader: 2 / 100%
revolution Is Recognizable
Rep Power: 4
Doesn't have to be javascript, can be whatever language, use MySQL, whatever.
__________________
Trades Completed:
Yummy, Kismet, Konekokoi, xRuinationx




 

 
Old 07-02-2008, 04:43 PM   #6 (permalink)
Banned
 
bug14 is offline
Join Date: Oct 2007
Location: bugmenot.com
Posts: 1,532
iTrader: 2 / 100%
bug14 Is a Lord of Awesomenessbug14 Is a Lord of Awesomenessbug14 Is a Lord of Awesomeness
Rep Power: 0
You can set a cookie with javascript, but the deleted row wouldn't be permanent.
 

 
Old 07-02-2008, 06:15 PM   #7 (permalink)
Underground
 
revolution's Avatar
 
revolution is offline
Join Date: Aug 2007
Location: Hiram, Georgia
Age: 19
Posts: 557
iTrader: 2 / 100%
revolution Is Recognizable
Rep Power: 4
Quote:
Originally Posted by bug14 View Post
You can set a cookie with javascript, but the deleted row wouldn't be permanent.
It would need to be permanent.

EDIT

nuke got it fixed
__________________
Trades Completed:
Yummy, Kismet, Konekokoi, xRuinationx





Last edited by revolution; 07-06-2008 at 10:27 AM.
 
Closed Thread

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 07:18 AM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.25924110 seconds (100.00% PHP - 0% MySQL) with 19 queries