Forums

This topic is locked

How do I Combine 2 Form Fields? (before Submit)

Posted 01 Oct 2007 23:31:05
1
has voted
01 Oct 2007 23:31:05 Owen Dess posted:
Could anyone provide me what I believe is a simple script (but beyond my current knowledge).

All my forms must call a PHP file as the ACTION.

This PHP file collects & processes the data into an email format my Database can Import Automatically (Goldmine).

I want to have the FIRSTNAME Field & the LASTNAME Field Combined into
ONE FIELD called CONTACT (BEFORE the Form Action calls my script).

For my PHP scripts to work properly, It Looks only for this CONTACT Field
(I don't program PHP either. This is Automatically generated via
Form1 Builder GoldMine www.softswot.com/FormGoldMineInfo.php )
I can have any fields (including hidden fields) I want, but I want the user
to see a seperate Firstname & Lastname Data Entry box, and my Database wants it entered into CONTACT, whereby it Automatically Pulls the Lastname Out & Put's it into a Lastname Field there.

Can a Javascript Populate this Before the Submit/Action calls my Formone Builder PHP file?
Is that the best/only way?

Thanks in advance.



Replies

Replied 05 Oct 2007 01:55:46
05 Oct 2007 01:55:46 Seb Adlington replied:
hi owen,

afew ways you can do it but i normally use a function in the header and then use an on change to populate a third field

in the head put your script
<script language=javascript>

funtion populate(){

Fname = document.form1.FirstName.value;
Lname = document.form1.LastName.value;

document.form1.CONTACT.value = Fname + " " + Lname;

}
</Script>

Then call the function with onchange on your lastname field <input ID="LastName" value="" onChange="populate()"

That's an easy enough way for you

Edited by - on 05 Oct 2007 02:07:34
Replied 05 Oct 2007 06:41:27
05 Oct 2007 06:41:27 Owen Dess replied:
Seb,

thankyou so much! You did it. That's just what I was looking for.

Blessings your way <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

Owen


Reply to this topic