I'll put in red the parts that are not quite clear to me
function writeCustomersArray(pName) Is that the table name, and do I have to change it to master, or viceversa?
We are going to write the data to a JavaScript array. pName, will be the name of the array. If you change it to master. any JavaScript function which references the array, will need to do so by calling master[idx][jdx].
if NOT (db_rs.bof AND db_rs.eof) then
out = "var "& pName &" = new Array();" & vbLF What is that referred to, shall I change it to some fileds I named differently?
idx = 0
while NOT db_rs.eof
out = out & " "& pName &"["& idx &"]=['" see above
pName is just the JavaScript array name. It has nothing to do with your field names.
writeCustomersArray = out & vbLF same as above
writeCustomersArray is the name of the function. When we assign a value to the function's name, that is what is returned. If you change it here, you will need to change every "writeCustomersArray" to reference the correct function name.
cmdText = "INSERT INTO log (Nome, Cognome, TipoDoc, NumeroDoc, Indirizzo, Data, in, out, Post ) VALUES (@Nome, @Cognome, @TipoDoc, @NumeroDoc, @Indirizzo, @Data, @In, @Out, @Post)"
I have changed those to be exactly like the db fields, is it ok?
Those are parameter place holders...the names are irrelevant. I always make mine match my field names as well.
addParam "@Nome",adVarChar,adParamInput,CLng(10),pNome,"addDetail 2a" Is that the lenght of the field?
Yes it is the length of the field and it must be passed as a Long Integer, hence the CLng() wrapper.
v v v This is the new piece in order to add the new user to master, did I put it in the right spot? v v v
Yes you did.
cmdText = "INSERT INTO master (customerid, key, TipoDoc, NumeroDoc, Indirizzo ) VALUES (@customerid, @key, @TipoDoc, @NumeroDoc, @Indirizzo)" Do they have to be like you put them, or do I have to change them with Nome and Cognome?
I usually match the field names, lile you did above, but they could be @1, @2, @3... it doesn't matter to the function. It does matter that you use the same parameter names in the addParam command to follow.
rXsafe, rXaddress, rXalpha
What's the difference, and did I edited them correctly?
If you look in the generalPurpose.asp file, you will see various regular expressions for filtering data.
rX is the prefix on the constant declarations, so rXalpha allows only a..z and A..Z
rXint only allows 0..9
rXaddress only allows characters that commonly are used in US postal addresses, which are not harmful in a database insert.
rXsafe allows about anything, that I feel will not cause a problem with XSS injections, but I hate to use it if I can be more precise about what my expected input should be. Here I used it many times because I was not sure what your true format would be for many fields.
If the field should only contain letters and numbers with no spaces (maybe the Doc number), use rXalphanumeric.
You can also send getFields a regular expression as a parameter.
So getField("postalCode,^[a-zA-Z]{1,2}[0-9][0-9A-Za-z]{0,1} {0,1}[0-9][A-Za-z]{2}$)
would validate a UK postal code.
' check for required fields here
if (Nome="") then
Message = "The Nome is required."
end if
' check more if you want
Is that to alert me if I fail to fill in the field, and that I can add as many checks as the form fields?
Yes. I was to lazy to write all the checks for all the fields <smile>. You can also check for other things, like relationships required between fields, or whatever. Probably should make all the Messages like this...
Message = "The Nome is required.<br>"
So they display nicely.]
<%=writeCustomersArray("customers")%>
Is the "customer" the db's table name? Shall I change it to "master"?
actualy, here the parameter "customers" is just setting the name of the JavaScript array. If you change that name, you'll need to chane all array references in your JavaScript.
[/quote]
function create
CustomerSelect() {
var tmpHTML = '<select id="myOptions" name="myOptions"';
tmpHTML += ' onchange="fillFormFields(this.selectedIndex);">';
tmpHTML = tmpHTML + ' <option>Select...</option>\n';
for (var idx=0; idx<
customers.length; idx++) {
tmpHTML = tmpHTML + ' <option>' +
customers[idx][0] + '</option>\n';
}
same as above tmpHTML = tmpHTML + '</select>';
return tmpHTML;
}
[/quote]
Again, array name, nothing to do with your table name.
} Same as the above, is "customers" the table name corresponding to my "master"?
}
array name, maybe I should have used jsArray or myArray in the example so as to not have confused you.
colspan="3"><input id="Post" name="Post" type="text" size="24">That is as in position, aka terminal, no zip code</td>
I was having trouble translating. You speak Italian, my wife speaks Vietnamese, VGR sprinkles his comments with French and my son cusses me out in Spanish. I'm an old American-Enlish speaker, and I'm doing my best to keep up with all of you, but I'm bound to misunderstand some. LOL.
Note I added id="" attributes to all your fields. Necessary for the getElementById(...) commands.
Also, I always make my database field names and form field names match exactly in both name and case. Same for variables in ASP. It makes it much much easier to know what input field is going to what database field.
Also, If you are running this on a box you control, I would switch from MS Access to MS SQL 2005 Express. It is free, light weight, has some free admin tools (or can be linked to via Access). It has standard SQL and is much more stable than Access. It also handles parameterized queries, views and stored procedures, which are impossible with access on the web.
It is a much better learning environment so you don't have to learn Access bad habits. (Weird and limited SQL, etc.)