The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

storing user input into a table

2 posters

Go down

Solved storing user input into a table

Post by shark7 April 9th 2011, 11:22 am

ok so I've got this code:

Code:
 <HTML>
<HEAD>
    <TITLE> Add/Remove dynamic rows in HTML table </TITLE>
    <SCRIPT language="javascript">
        function addRow(tableID) {
 
            var table = document.getElementById(tableID);
 
            var rowCount = table.rows.length;
            var row = table.insertRow(rowCount);
 
            var cell1 = row.insertCell(0);
            var element1 = document.createElement("input");
            element1.type = "text";
            cell1.appendChild(element1);

            var cell2 = row.insertCell(1);
            var element2 = document.createElement("input");
            element2.type = "text";
            cell2.appendChild(element2);
 

            var cell3 = row.insertCell(2);
            var element3 = document.createElement("input");
            element3.type = "text";
            cell3.appendChild(element3);

            var cell4 = row.insertCell(3);
            var element4 = document.createElement("input");
            element4.type = "text";
            cell4.appendChild(element4);

            var cell5 = row.insertCell(4);
            var element5 = document.createElement("input");
            element5.type = "text";
            cell5.appendChild(element5);

            var cell6 = row.insertCell(5);
            var element6 = document.createElement("input");
            element6.type = "text";
            cell6.appendChild(element6);

            var cell7 = row.insertCell(6);
            var element7 = document.createElement("input");
            element7.type = "checkbox";
            cell7.appendChild(element7);
 
        }
 
        function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
 
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[6].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }
 
            }
            }catch(e) {
                alert(e);
            }
        }
 
    </SCRIPT>
</HEAD>
<BODY>
 
    <INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />
 
    <INPUT type="button" value="Delete Row" onclick="deleteRow('dataTable')" />
 
    <TABLE id="dataTable" border="1">
        <TR>
            <TD width="160px"> I </TD>
            <TD width="160px"> banned </TD>
            <TD width="160px"> because of </TD>
            <TD width="160px"> for </TD>
            <TD width="160px"> on the </TD>
            <TD width="160px"> remaining time </TD>
            <TD width="40px"> Delete? </TD>
        </TR>
    </TABLE>
 
</BODY>
</HTML>

adding new rows and deleting them works fine, but when I refesh the page, everything is reset.

I realise this is because the data being input isnt being sent to a db, so i was wondering if it was possible to do it any other way, OR by linking ir to an off site db, then calling that database back for input?

question breakdown: what should i do to my code to make the inputs stay there permanently?

NOTE: this is a ban list to keep track of bans other than my forums bans. eg a TF2 server ban list.
shark7
shark7
New Member

Male Posts : 24
Reputation : 0
Language : English

Back to top Go down

Solved Re: storing user input into a table

Post by shark7 April 14th 2011, 3:08 pm

for anyone who was wondering how i solved this ... i set up a google spreadsheet/ form, then used the <iframe> tage to crate a submission page and a table view page.

IM me if you want more info Very Happy
shark7
shark7
New Member

Male Posts : 24
Reputation : 0
Language : English

Back to top Go down

Solved Re: storing user input into a table

Post by Jophy April 15th 2011, 2:24 pm

Solved -> Locked
Jophy
Jophy
ForumGuru

Male Posts : 17924
Reputation : 836
Language : English
Location : Somewhere

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum