Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    form fields - filling them automatically

    Hi. I hope/reckon this is a javascript question. if not please move it to the right place.

    I have hundreds of pages with a hyperlink image to take you to a standard form. I want to use only one 'instance' of the form.
    Is there a way in which when I click on the image button to go to the form, it can also fill in the first box on the form and determine the email address to which the form will be sent?

    This way, i can upload only the one form and the individual buttons from the hundreds of pages can tailor the form for that particular use.

    Please say it can be done. Oh and if you could show me how I'd be really chuffed.

    thanks.

    I cant send you the srcipt yet coz it aint uploaded and relies on a .css file for its appearance.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    chuffed? That's good, right?

    Without using server-side scripting (which would be much better) you have two choices

    1) pass the data on the query-string
    2) pass the data with a cookie

    #1 pros
    Easy
    #1 cons
    hard to make secure

    #2 pros
    More secure than #1
    #2 cons
    require user is using cookies
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Beyond Lament
    Posts
    424
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Couldn't one pass that information across frames/iframes?
    Quíet Storm Designs ~ Art is not what you see, but what you make others see.
    · the Storms· || ·Ultraviolent Winter· || ·Was Einstein Wrong?· || ·It´s About Time!·

  • #4
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    Yup, Beetle. Chuffed = very pleased.

    I'd prefer to try server side scripting but dunno how to do it. If you're able to help me with it then I would take that route. I'll try anything (well nearly), once.

    If you can help Beetle and the writing of the script isnt too time consuming, can you do it or explain to me how it is done?


    thanks.
    Last edited by bazz; 04-04-2003 at 06:37 PM.

  • #5
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, what exactly needs to change? What in this form will be 'flexible'?
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”

  • #6
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    I'll write the form in ordinary HTML (ie without the need for .css) and upload it here. Presently the first text box is the name of the sender followed by the usual addresses etc.

    I want to preceed the first text box (or add an earlier one) where the name of a business will be displayed when the form presents itself to the user (perhaps from the clicking of the hyperlink on the previous page?) Then when they click submit at the bottom of the form (after it is completed), the form is sent to the email address for that business (perhaps where this email address has been added to the script of the form by the same hyperlink?)

    I'll try to think of an easier explanation as I upload the script.

    thanks

  • #7
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    OK, I've included here, the script from two pages.

    The first is the hyperlink taking you to the form:


    <a href="form.htm">click to go to form</a>

    Then below is the main parts of the script for the form itself.

    Just to recap (saving you re-reading the whole thread), I'm looking for a way to use the same single form for many clients. So I need to have an instruction (perhaps in the hyperlink) to complete two parts of the form so that it is customised for each use.

    1. The name of the busines to which the form is to be sent, which should display as ordinary text in the sent message. (Text Box 1)

    2. To add to the form the destination email address (for this occasion only) so that when the submit button is 'pressed', that is where the message goes. This idea would allow for another user, from another page to use this same form, with the appopriate email address for that occasion, being applied from the hyperlink that they have used to reach the form.

    Maybe what I'm looking for isn't javascript or perhaps you know of a better way. I'm open minded as to the solution but my skills are relatively primitive.

    BTW I dont use wysiwyg anymore



    <!DOCTYPE HTML PUBLIC "-//SoftQuad//DTD HoTMetaL PRO 5.0::19981022::extensions to HTML 4.0//EN" "hmpro5.dtd">

    <HTML>

    <HEAD>
    <TITLE></TITLE>
    <META NAME="DESCRIPTION" CONTENT="">
    <META NAME="KEYWORDS" CONTENT="">
    </HEAD>

    <BODY BGCOLOR="#FFFFFF">
    <BLOCKQUOTE><P><B>Form</B></P>
    <P ALIGN="LEFT">Please complete all sections of our online form and click the Submit button.</P>

    <!--webbot BOT="GeneratedScript" PREVIEW=" " startspan --><SCRIPT LANGUAGE="JavaScript">
    <!--
    function FrontPage_Form1_Validator(theForm)
    {

    if (theForm.surname.value == "")
    {
    alert("Please enter a value for the \"surname\" field.");
    theForm.surname.focus();
    return (false);
    }

    if (theForm.surname.value.length < 2)
    {
    alert("Please enter at least 2 characters in the \"surname\" field.");

    theForm.surname.focus();
    return (false);
    }

    if (theForm.firstname.value == "")
    {
    alert("Please enter a value for the \"firstname\" field.");
    theForm.firstname.focus();
    return (false);
    }

    if (theForm.firstname.value.length < 3)
    {
    alert("Please enter at least 3 characters in the \"firstname\" field.");
    theForm.firstname.focus();
    return (false);
    }

    if (theForm.address1.value == "")
    {
    alert("Please enter a value for the \"address1\" field.");
    theForm.address1.focus();
    return (false);
    }

    if (theForm.address1.value.length < 3)
    {
    alert("Please enter your address in the \"address1\" field.");
    theForm.address1.focus();
    return (false);
    }

    if (theForm.address2.value == "")
    {
    alert("Please enter a value for the \"address2\" field.");
    theForm.address2.focus();
    return (false);
    }

    if (theForm.address2.value.length < 5)
    {
    alert("Please enter your City in the \"address2\" field.");
    theForm.address2.focus();
    return (false);
    }

    if (theForm.address3.value == "")
    {
    alert("Please enter a value for the \"address3\" field.");
    theForm.address3.focus();
    return (false);
    }

    if (theForm.address3.value.length < 5)
    {
    alert("Please enter your country in the \"address3\" field.");
    theForm.address3.focus();
    return (false);
    }

    if (theForm.zip.value == "")
    {
    alert("Please enter a value for the \"zip\" field.");
    theForm.zip.focus();
    return (false);
    }

    if (theForm.zip.value.length < 6)
    {
    alert("Please enter your Post Code/Zip in the \"zip\" field.");
    theForm.zip.focus();
    return (false);
    }

    if (theForm.telephone.value == "")
    {
    alert("Please enter a value for the \"telephone\" field.");
    theForm.telephone.focus();
    return (false);
    }

    if (theForm.telephone.value.length < 6)
    {
    alert("Please enter your telephone number in the \"telephone\" field.");
    theForm.telephone.focus();
    return (false);
    }

    if (theForm.fax.value == "")
    {
    alert("Please enter a value for the \"fax\" field.");
    theForm.fax.focus();
    return (false);
    }

    if (theForm.fax.value.length < 6)
    {
    alert("Please enter the correct number in the \"fax\" field.");
    theForm.fax.focus();
    return (false);
    }

    if (theForm.email.value == "")
    {
    alert("Please enter a value for the \"email\" field.");
    theForm.email.focus();
    return (false);
    }

    if (theForm.email.value.length < 6)
    {
    alert("Please enter your mobile number in the \"email\" field.");
    theForm.email.focus();
    return (false);
    }

    if (theForm.eta.value == "")
    {
    alert("Please enter a value for the \"eta\" field.");
    theForm.eta.focus();
    return (false);
    }

    if (theForm.eta.value.length < 4)
    {
    alert("Please enter your Estimated time of arrival in the \"eta\" field.");
    theForm.eta.focus();
    return (false);
    }
    return (true);

    }
    //-->
    </SCRIPT>
    <!--webbot BOT="GeneratedScript" endspan -->

    </P>
    <BLOCKQUOTE>
    <FORM METHOD="POST" ACTION="http://www.metronet.co.uk/cgi-bin/formmail.pl" ONSUBMIT="return FrontPage_Form1_Validator(this)" NAME="FrontPage_Form1">
    <!-- Edit this line -->
    <INPUT TYPE="hidden" NAME="recipient" VALUE="client email address;my email address">
    <!-- Edit this line -->
    <INPUT TYPE="hidden" NAME="subject" VALUE="Online form entry.">
    <!-- Edit this line -->
    <INPUT TYPE="hidden" NAME="redirect" VALUE="http://www.client_domain_name/reply.htm">
    <!-- Edit this line -->
    <INPUT TYPE="hidden" NAME="title of message" VALUE="name of business">
    <!-- Edit this line -->
    <INPUT TYPE="hidden" NAME="Referral" VALUE="page/site from where form came">
    <!--webbot bot="SaveResults" endspan i-checksum="43374" -->
    <TABLE BORDER="0" CELLSPACING="2" CELLPADDING="0">
    <TR>
    <TD><P><B>Name of Business</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="2" --><INPUT TYPE="text" NAME="Name of Business" SIZE="20"></TD><tr>
    <TD><P><B>Surname:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="2" --><INPUT TYPE="text" NAME="surname" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>First Name(s):</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="3" --><INPUT TYPE="text" NAME="firstname" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Address 1:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="5" --><INPUT TYPE="text" NAME="address1" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Address 2:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="5" --><INPUT TYPE="text" NAME="address2" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Address 3:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="5" --><INPUT TYPE="text" NAME="address3" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Postcode/Zipcode:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="6" --><INPUT TYPE="text" NAME="zip" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Telephone:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="6" --><INPUT TYPE="text" NAME="telephone" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Fax:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="6" --><INPUT TYPE="text" NAME="fax" SIZE="20"></TD>
    </TR>
    <TR>
    <TD><P><B>Email:</B></P>
    </TD>
    <TD><!--webbot bot="Validation" S-Data-Type="String" B-Value-Required="TRUE" I-Minimum-Length="6" --><INPUT TYPE="text" NAME="email" SIZE="25"></TD>
    </TR>
    </TABLE>
    <P ALIGN="CENTER"><INPUT TYPE="submit" VALUE="Send" NAME="B1"><INPUT TYPE="reset" VALUE="Start over" NAME="B2"></P>
    </FORM>
    </BLOCKQUOTE>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •