Results 1 to 4 of 4

Thread: Filling out a form to access a page

  1. #1
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Filling out a form to access a page

    Don't necessarely have to worry about my extensive copy and paste below, it all seems to work fine. except variables its unedited from something i found here.

    Basically I need to have the site ask for some information from someone wanting to download before they can. The form works, but i have no clue as to how to get the filled out content parsed to another source, like a separate text file.

    Can anyone help? I barely know what im doing here but im pretty sure theres a way to write to file, at least i've done that in java sometime... long ago.
    Many thanks

    This is what it looks like
    -Franz
    <script language="JavaScript">
    <!--

    /***********************************************
    * Required field(s) validation v1.10- By NavSurf
    * Visit Nav Surf at http://navsurf.com
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    function formCheck(formobj){
    // Enter name of mandatory fields
    var fieldRequired = Array("FirstName", "LastName", "Email");
    // Enter field description to appear in the dialog box
    var fieldDescription = Array("First Name", "Last Name", "E-mail");
    // dialog message
    var alertMsg = "Please complete the following fields:\n";

    var l_Msg = alertMsg.length;

    for (var i = 0; i < fieldRequired.length; i++){
    var obj = formobj.elements[fieldRequired[i]];
    if (obj){
    switch(obj.type){
    case "select-one":
    if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    break;
    case "select-multiple":
    if (obj.selectedIndex == -1){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    break;
    case "text":
    case "textarea":
    if (obj.value == "" || obj.value == null){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    break;
    default:
    }
    if (obj.type == undefined){
    var blnchecked = false;
    for (var j = 0; j < obj.length; j++){
    if (obj[j].checked){
    blnchecked = true;
    }
    }
    if (!blnchecked){
    alertMsg += " - " + fieldDescription[i] + "\n";
    }
    }
    }
    }

    if (alertMsg.length == l_Msg){
    return true;
    }else{
    alert(alertMsg);
    return false;
    }
    }
    // -->
    </script>


    Before you download your AppTONE trial, please provide us with the following information so that we may better serve you:<br><br><br>

    <form action="form.processed.html" name="formcheck" onsubmit="return formCheck(this);">

    <table border=0>
    <tr>
    <td>First Name*: </td><td><input type=text name="FirstName" size="30"></td>
    </tr>
    <tr>
    <td>Last Name*: </td><td><input type=text name="LastName" size="30"></td>
    </tr>
    <tr>
    <td>E-mail*:</td><td><input type=text name="Email" size="30"></td>
    </tr>
    <tr>
    <td>Company:</td><td><input type=text name="Company" size="30"></td>
    </tr>
    <tr>
    <td>Phone:</td><td><input type=text name="Phone" size="30"></td>
    </tr>
    <tr>
    <td colspan=2>Address</td>
    </tr>
    <tr>
    <td>City:</td><td><input type=text name="Address" size="15">State:<input type=text name="Address" size="2"></td>
    </tr>
    </table>



    <input type=submit value="Submit and Download AppTONE">
    </form>
    *Required Fields
    Last edited by Franz; 12-24-2009 at 06:11 PM.

  2. #2
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    *bump* it just occurred to me that javascript runs client side(so i cant write to file on server....) but i rly dont want to go into php cuz i dont know how.... is there something like dynamic drive for php where i could get a ready-made form kit?

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,412
    Thanks
    78
    Thanked 3,432 Times in 3,393 Posts
    Blog Entries
    12

    Default

    Javascript cannot write to a file. Javascript can utilize Active X (IE only) or Java (not javascript, available to any browser that has the Java plug-in) to write to a file on the user's machine. But there are almost always high security restrictions against that. A long time ago, there were not. Perhaps that's what you're remembering. The best way now to get a file to your users is to write it on the server and get them to download it or copy from it.

    If you have a server side language like PHP, asp, etc. available to you on your host and its permissions are set to allow you to write to a file or set session variables, one can write to a file on the server or set a session variable (for among other things generating a page the user can view and copy from). This is relatively easy to do. It varies by which language you use. Most if not all of these server side languages have one or more decent online tutorials that can be found using Google. The PHP forum here is a good source of help with PHP. Our asp forum is a bit weak. Other forums exist for these languages and can also be found using Google.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    =p i guess i have to learn php then, thanks for the explanation

Bookmarks

Posting Permissions

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