...

View Full Version : Need help creating data entry form



enfleshjsc
08-09-2006, 08:12 PM
I am new to Javascript and need to create a data entry form for inputting new records into a MySQL database (I will worry about the PHP code later). The first 4 fields for each record should be the same. I need the user to input or select the values for those first 4, choose how many records are to be added, and click a button that will then populate the data entry table with the duplicate values and empty textboxes for the rest of the fields. Right now when I click the button nothing happens. :confused: Please help!

This is what I have so far: http://www.darkhologram.com/dep1.php

The external .js file contains the following code:



function addRowsNS()
{
var mytbody = document.getElementsByTagName("tbody")
var norowopt = document.getElementById("dei12");
var poval = document.getElementById("dei1");
var odate = document.getElementById("dei2");
var oby = document.getElementById("dei3");
var vendval = document.getElementById("dei4");
for (var nr=0;nr<norowopt;nr++)
{
// creates new row <tr>
row[nr] = document.createElement("tr");
// creates cells <td>
cella[nr] = document.createElement("td");
cellb[nr] = document.createElement("td");
cellc[nr] = document.createElement("td");
celld[nr] = document.createElement("td");
celle[nr] = document.createElement("td");
cellf[nr] = document.createElement("td");
cellg[nr] = document.createElement("td");
cellh[nr] = document.createElement("td");
celli[nr] = document.createElement("td");
cellj[nr] = document.createElement("td");
cellk[nr] = document.createElement("td");
// creates forms
forma[nr] = document.createElement("form");
formb[nr] = document.createElement("form");
formc[nr] = document.createElement("form");
formd[nr] = document.createElement("form");
forme[nr] = document.createElement("form");
formf[nr] = document.createElement("form");
formg[nr] = document.createElement("form");
formh[nr] = document.createElement("form");
formi[nr] = document.createElement("form");
formj[nr] = document.createElement("form");
formk[nr] = document.createElement("form");
// set the Forms method
forma[nr].method = "POST";
formb[nr].method = "POST";
formc[nr].method = "POST";
formd[nr].method = "POST";
forme[nr].method = "POST";
formf[nr].method = "POST";
formg[nr].method = "POST";
formh[nr].method = "POST";
formi[nr].method = "POST";
formj[nr].method = "POST";
formk[nr].method = "POST";
// creates Text Inputs
inputa[nr] = document.createElement("input");
inputb[nr] = document.createElement("input");
inputc[nr] = document.createElement("input");
inputd[nr] = document.createElement("input");
inpute[nr] = document.createElement("input");
inputf[nr] = document.createElement("input");
inputg[nr] = document.createElement("input");
inputh[nr] = document.createElement("input");
inputi[nr] = document.createElement("input");
inputj[nr] = document.createElement("input");
inputk[nr] = document.createElement("input");
// sets 1st 4 input values
inputa[nr].value = poval.value;
inputb[nr].value = odate.value;
inputc[nr].value = oby.value;
inputd[nr].value = vendval.selectedIndex.value;
// appends the inputs to the forms
forma[nr].appendChild(inputa[nr]);
formb[nr].appendChild(inputb[nr]);
formc[nr].appendChild(inputc[nr]);
formd[nr].appendChild(inputd[nr]);
forme[nr].appendChild(inpute[nr]);
formf[nr].appendChild(inputf[nr]);
formg[nr].appendChild(inputg[nr]);
formh[nr].appendChild(inputh[nr]);
formi[nr].appendChild(inputi[nr]);
formj[nr].appendChild(inputj[nr]);
formk[nr].appendChild(inputk[nr]);
// appends the forms into the cells <td>
cella[nr].appendChild(forma[nr]);
cellb[nr].appendChild(formb[nr]);
cellc[nr].appendChild(formc[nr]);
celld[nr].appendChild(formd[nr]);
celle[nr].appendChild(forme[nr]);
cellf[nr].appendChild(formf[nr]);
cellg[nr].appendChild(formg[nr]);
cellh[nr].appendChild(formh[nr]);
celli[nr].appendChild(formi[nr]);
cellj[nr].appendChild(formj[nr]);
cellk[nr].appendChild(formk[nr]);
// appends the cells <td> to the row <tr>
row[nr].appendChild(cella[nr]);
row[nr].appendChild(cellb[nr]);
row[nr].appendChild(cellc[nr]);
row[nr].appendChild(celld[nr]);
row[nr].appendChild(celle[nr]);
row[nr].appendChild(cellf[nr]);
row[nr].appendChild(cellg[nr]);
row[nr].appendChild(cellh[nr]);
row[nr].appendChild(celli[nr]);
row[nr].appendChild(cellj[nr]);
row[nr].appendChild(cellk[nr]);
// appends the row <tr> into <tbody>
mytbody.appendChild(row[nr]);
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum