Hello all,
I downloaded and used your formmail script and it's working great. However, I was hoping if you can help me out with this little problem I'm having. I'm a programming newbie so any help I can get I would appreciate it.
I have a form that appears like this:
----------------------------------------------------------------------------------
Untitled Document
// Last updated 2005-03-08
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode('phone number');
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'phonenumber' + iteration);
el.setAttribute('id', 'phonenumber' + iteration);
el.setAttribute('size', '10');
cellRight.appendChild(el);
}
//-->
function addRowToTable2()
{
var tbl = document.getElementById('tblSample2');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode('existing number');
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el2 = document.createElement('input');
el2.setAttribute('type', 'text');
el2.setAttribute('name', 'existingnumber' + iteration);
el2.setAttribute('id', 'existingnumber' + iteration);
el2.setAttribute('size', '10');
cellRight.appendChild(el2);
}
//-->
Name
phone number
existing number
----------------------------------------------------------------------------------
It's working and all, sending the results via email, but the thing is, when I receive the email I get it in this order:
name: ***
email: ***@hotmail.com
email2: ***@yahoo.com
phonenumber: 12345
existingnumber: qwerty
phonenumber1: 12345
existingnumber1: qwerty
Note that the email and email2 appear in order, whereas the phonenumber and existingnumber fields swap places (sorry i dont know the correct term). I want it to appear like this:
name: ***
email: ***@hotmail.com
email2: ***@yahoo.com
phonenumber: 12345
phonenumber1: 12345
existingnumber: qwerty
existingnumber1: qwerty
I'm thinking it has something to do with the javascript functions in the section, but I'm not sure. Any help please?
Thanks!
help in formatting email output
While I don't know about the javascript you could always add the hidden input for the fields to be sorted. See: Sort
-Andrew Riley
help in formatting email output
I've already tried adding the sort feature
but the output didnt change at all.
I was wondering if i needed to add the 'phonenumber'+iteration to the sort value, but i dont know the syntax. I tried
and that sort of worked, as it forced the output to be like this:
name: ***
email: ***@hotmail.com
email2: ***@yahoo.com
phonenumber: 12345
existingnumber: qwerty
existingnumber1: qwerty
phonenumber1: 12345
So I tried it like this:
So it worked. Just wanted to ask if any of you know a better way of doing this?