#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    5
    Rep Power
    0

    CGI FORM Submit >> Javascript [HELP]


    I need to be able to convert this form (I've edited some of the fields for content reasons) , which uses the following two scripts (one to validate, one for the submit), and have it POST the results as a Query String which I can pass along to another URL designed to handle the results.

    Let's say the url is: http://www.whereever.com/Engine.asp?

    The text input fields are collected mostly like this:

    11.zip
    4.firstname
    5.lastname

    and so on...the FORM action is...

    <form name="tshirt" onSubmit="return submit_form(tshirt);" action="/cgi-bin/ipoform_engine.cgi" method="post">

    Which I need to do as a JavaScript submit and not CGI..?? would I just specify the action to be action="http://www.whereever.com/Engine.asp?"

    What if I collected all of the data into an associative array how would I load into the action when it submits...???

    If anyone has any thoughts or help...I'll repay the favor in kind.

    Thanks!

    Agent_Coop
    http://www.templatekit.com


    Here's the script:


    <script language="JavaScript">
    <!--
    function submit_form(thisform) {

    var not_filled;
    var num_not_filled;
    num_not_filled=0;
    not_filled="";
    all_required=true;

    if (!thisform[3].value) {all_required=false; not_filled=not_filled + 'E-mail Address, '; ++num_not_filled;}
    if (!thisform[4].value) {all_required=false; not_filled=not_filled + 'First Name, '; ++num_not_filled;}
    if (!thisform[5].value) {all_required=false; not_filled=not_filled + 'Last Name, '; ++num_not_filled;}


    if (!all_required){
    not_filled=not_filled.substring(0, not_filled.length-2)
    alert('The following information is required, but was not entered: ' + not_filled + '.');
    return(false);
    }

    if (!isEmail(thisform[3].value)) {
    alert('A valid E-mail address is required to register for this promotion.');
    return(false);
    }

    answered = true;

    checked=false;

    if (thisform[2].checked) {checked=true;}

    if (!checked) {answered = false;}

    if (!answered) {
    alert("You must agree to give us permission in order to register for this promotion.");
    return(false);
    }

    }

    function isEmail(str) {
    // are regular expressions supported?
    var supported = 0;
    if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
    }
    if (!supported)
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
    var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
    var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
    return (!r1.test(str) && r2.test(str));
    }

    //-->
    </script>

    Then this is the bulk of the FORM:

    <form name="tshirt" onSubmit="return submit_form(tshirt);" action="/cgi-bin/ipoform_engine.cgi" method="post">
    <input type="hidden" name="config" value="tshirt">
    <input type="hidden" name="1.code" value="$key">
    To get your FREE T-shirt and begin receiving the latest promotions and product information from FDG, please
    provide the required information below, then hit Submit.
    <br><br>
    Remember, in order to get your free T-shirt, you must agree to receive e-communications from FDG by
    checking the "Yes!" box below and provide your name and valid e-mail address. T-shirt available only while
    supplies last. No purchase necessary.<br><br>

    <a href="http://www.templatekit.com/privacy/yourprivacy.shtml"><img src="http://www.templatekit.com/i/v11/buttons/your_privacy.gif" alt="Your Privacy" border="0"></a><br><br>
    This data may be used to provide you with information from FDG or selected organizations worldwide about
    products, services or activities that may be of interest to you.<br><br>
    <table width="516" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="25" align="left" valign="top"><input type="checkbox" name="2.agree" value="Yes"></td>
    <td width="491" valign="top"><b>Yes!</b> Please sign me up to receive valuable e-communications about
    FDG products and services that are relevant to my business needs. Also send me a FREE T-shirt!</td>
    </tr>
    </table>
    <br>
    The fields indicated with an asterisk are required to complete this transaction; other fields are optional.
    By submitting this form you are consenting to receive e-mail from FDG. If you don't wish to provide us with
    the required information or consent to receive e-mail, please use the back button on your browser to return to
    the previous page.<br><br>
    <table width="516" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="175"><b>* E-mail Address:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="UniqueCust"></td>
    </tr>
    </table>
    <br>
    We will use this e-mail address to send your confirmation notice. Your valid e-mail address is required
    to receive your free T-shirt.<br><br>

    Please enter your name below for verification purposes:<br><br>
    <table width="516" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="175"><b>* First Name:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="first_name"></td>
    </tr>

    <tr><td width="175"><b>* Last Name:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="last_name"></td>
    </tr>
    </table>
    <br>
    We'll use the address we have on file to mail you your free T-shirt. If your business has recently
    moved you can update your record below.<br><br>

    <table width="516" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="25" align="left" valign="top"><input type="checkbox" name="6.update" value="Yes">
    <input type="hidden" name="6.update" value="No"></td>
    <td width="491" valign="top"><b>I've moved!</b> Please update your records to reflect my new business address.</td>
    </tr>
    </table>
    <br>

    <table width="516" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="175"><b>Company Name:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="7.company"></td>
    </tr>

    <tr><td width="175"><b>Title:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="8.title"></td>
    </tr>

    <tr><td width="175"><b>Address:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="9.address1"></td>
    </tr>

    <tr><td width="175"></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="10.address2"></td>
    </tr>

    <tr><td width="175"><b>City:</b></td>
    <td width="341"><input type="text" size="22" class="iform" style="width: 195px" name="11.city"></td>
    </tr>

    <tr><td width="175"><b>State:</b></td>
    <td width="341"><select name="12.state" class="iform" style="width: 201px" style="width: 173px">
    <option selected value="">Select One</option>
    <option value="Alabama">Alabama</option>
    <option value="Alaska">Alaska</option><!-- I've edited the states -->
    <option value="Washington">Washington (State)</option>
    <option value="DC">Washington, D.C.</option>
    <option value="West Virginia">West Virginia</option>
    <option value="Wisconsin">Wisconsin</option>
    <option value="Wyoming">Wyoming</option>
    </select></td></tr></table>

    <table width="516" cellpadding="0" cellspacing="0" border="0"><tr><td width="175"><b>ZIP Code:</b></td>
    <td width="205"><input type="text" size="22" class="iform" style="width: 195px" name="13.zip"></td>
    <td width="136"></td></tr>
    <tr><td width="175" valign="top"><b>Business Phone:</b></td>
    <td width="205" valign="top"><input type="text" size="22" style="width: 195px" class="iform" name="14.phone"></td>
    <td width="136"><img src="http://www.templatekit.com/dm/tshirt/images/thinkpad_top.jpg" width="136" height="36" border="0"></td>
    </tr></table>
    <table width="516" cellpadding="0" cellspacing="0" border="0">
    <tr><td width="324"><input type="image" src="http://www.templatekit.com/i/v11/buttons/submit.gif" width="120" height="21" border="0" alt="Submit" /></td>
    <td width="192"><img src="http:/dm/tshirt/images/thinkpad_bot.jpg" width="192" height="100" border="0"></td>
    </tr></table></form>
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    5
    Rep Power
    0
    Ack! I know it is long..but..

    If anyone wants to help me one on one with this...I'll get you a reviewer copy of our Proposal Kit software product! Fully functional...$197 value.

    Thanks,

    Coop
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    5
    Rep Power
    0
    All done..offer off the table!

IMN logo majestic logo threadwatch logo seochat tools logo