Results 1 to 21 of 21

Thread: Very basic Submit form question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Question Very basic Submit form question

    I have a form with a couple of text fields that get emailed to me when the user clicks Submit. What I am trying to do is show an alert message box saying Thank you your request has been submitted. Or Redirect to a Thank you page. I just can't seem to get Both the Submit button and the redirect to work together. Below is my code with out the redirect or alert..

    <HTML>
    <Tile><h1> Action Request Form </h1></Tilte>
    <HEAD>


    </Head><BODY bgColor=White>
    <HR>
    <FORM METHOD="post" ACTION= "mailto:[email protected]?subject=Action Request" ENCTYPE="text/plain">

    <h1> Name:</h1>
    <INPUT NAME="name" SIZE="30" >
    <h1> Description:</h1><TEXTAREA name=Description rows=6 cols=40></TEXTAREA>
    <h1>How Soon is This Needed? </h1>
    <INPUT TYPE="radio" NAME=Time VALUE="Urgent">
    Urgent
    <br>
    <INPUT TYPE="radio" NAME=Time VALUE="ASAP">
    ASAP
    <br>
    <INPUT TYPE="radio" NAME=Time VALUE="Tomorrow">
    Tomorrow
    <br>
    <INPUT TYPE="radio" NAME=Time VALUE="Couple of Days">
    Couple of Days
    <br>
    <INPUT TYPE="radio" NAME=Time VALUE="When Ever">
    When Ever
    <P>
    <br><BR>

    <INPUT TYPE="submit" id=submit1 value="Submit" name=submit1 >


    <INPUT TYPE="reset" value=Reset>
    </FORM></P></BODY></HTML>
    TMacPherson
    MIS Systems Engineer
    [email protected]


  2. #2
    scoutt
    Guest
    here is a message box that comes up.
    you need to put this in your document right after you <body> tag
    Code:
    <SCRIPT LANGUAGE="JavaScript">
    function checkdata()
    {
         var uppervalue;
         if (document.WF_1.NAME.value.length == 0) {
             alert ("The 'Name' field requires an entry.");
             return false;
         }
         if (document.WF_1.Description.value.length == 0) {
             alert ("The 'Description' field requires an entry.");
             return false;
         }
         if (document.WF_1.time.value.length == 0) {
             alert ("The 'Time' field requires an entry.");
             return false;
         }
         return confirm('Thank You, Your application has been sent.');
    }
    // -- End of JavaScript code -------------- -->
    </script>
    then put this in your <form> tag-
    Code:
    onSubmit="return checkdata()"
    if this doesn't work, you might need to put "name=WF_1" in your form tag.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Still get error on WF_1.time

    Thanks Scoutt,

    It works I did have to put name="WF_1" in the Form Tag. also I had to give the name text a type of "text" <INPUT NAME="name" type="text" SIZE="30" >. I still get an Error on the Radio Buttons.
    if (document.WF_1.time.value.length == 0) {
    alert ("The 'Time' field requires an entry.");
    return false;
    }
    The error is document WF_1.time.value.legnth is null or not an object. any ideas?

    I got the same error on the WF_1 name but I noticed name was Capitalized Name after changing it that and the description fields work.

    Troy
    TMacPherson
    MIS Systems Engineer
    [email protected]


  4. #4
    scoutt
    Guest
    sorry my fault. I wasn't sure if that would work with radio buttons. so here is another one that checks for radio buttons. look closely as the form tag is in the javascript.

    Can you use cgi? I think it would be easier to use that instead of javascript.
    Code:
    <script Language="Javascript">
    
    <!-- Hide
    function myWindow() {
      if(!checkform()) return false;
        
      var Name=document.WF_1.Name.value
      var Description=document.WF_1.Description.value
        
      var Time=document.WF_1.Time  // it's an array...
      for (var i=0;i < Time.length; i++){   // loop thru the array
          if (Time[i].checked){             // if i. radio box is checked
             Time = Time[i].value  // passing its value to Time
             break;                                  // and jump out from the loop  
          }
      }
      
    
    formwindow=window.open("","formwindow","width=240,height=420,scrollbars=yes");
    formwindow.document.write("<center><b>Is This Correct?</b></center>")
    formwindow.document.write("<FORM NAME='myWindow'")
    formwindow.document.write(" ACTION='mailto:[email protected]?subject=Action Request'")
    formwindow.document.write(" ENCTYPE='TEXT/PLAIN'>")
    
    // START OF PASSING DATAS TO THE WINDOW
    // THE "PLACE" TO PASS
    formwindow.document.write("<INPUT TYPE=hidden NAME=BODY>")
    // MAKIN' AN "ALIAS"
    msgData = formwindow.document.myWindow.BODY;
    // PASSIN' THE DATA
    msgData.value += "Name=" + escape(" ")+ Name + unescape("\n");
    msgData.value += "Description=" + escape(" ")+ Description + unescape("\n");
    msgData.value += "When=" + escape(" ")+ Time + unescape("\n");
    
    // END OF PASSING DATAS TO THE WINDOW
    
    formwindow.document.write("<center><b>Name=</b> ", Name,"<br>"+"<b>Description=</b> ",Description,"<br>"+"<b>When=</b> ", Time,"<br><br></center>");
    
    formwindow.document.write("<center>If this is not the correct information")
    formwindow.document.write(" then just close this window and fix what you have to.<br></center>");
    formwindow.document.write("<center><INPUT TYPE='Submit' VALUE='Submit'></center>")
    formwindow.document.write("</form>")
    formwindow.document.close();            
    return false                   
    }
    
    function checkform() {
          valid=true;
          if(document.WF_1.Name.value=="") {
            valid=false ;
            alert("Please fill in the Name: textbox!");
          }
          if(document.WF_1.Description.value=="") {
            valid=false ;
            alert("Please fill in the Description: textbox!");
          }
          
          return valid;
          
    }
    //-->
    </script>
    then in your form part put this in place of your other form tag

    <FORM NAME="WF_1" METHOD="POST" ENCTYPE="TEXT/PLAIN">
    and then in your submit put this

    <INPUT TYPE="button" VALUE="Submit" NAME="Submit" onClick="return myWindow()">

    you don't have to have WF_1, you can change that to whatever you want, just make sure you get them all if/when you do.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    I can use CGI I just don't know enough about it

    I can use CGI I just don't know enough about it. If you have a CGI script for something like this maybe you can post it and I will give it a go! I tried the code from your last reply. It doesn't look at the radio buttons? nor will the mailto work? I have been trying to debug it but I'm not very good at HTML and Scripts. I am mainly a VB user.

    -Troy
    TMacPherson
    MIS Systems Engineer
    [email protected]


  6. #6
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    i'm pretty sure it's because time is a reserved word

    just put theTime instead, or whatever

  7. #7
    scoutt
    Guest
    why don't you post the form you have and I will make you a script that will work just for your form. just put it in a text file and upload it.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Great Thanks!!

    Here it is
    TMacPherson
    MIS Systems Engineer
    [email protected]


  9. #9
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    what is WF_1,

    anyway,

    give a name to your form and do

    document.yourFormName.yourFieldName.value

    or

    document.forms[0].yourFieldName.value

    BUT you should not use time as a field name,

    it sort of a reserve word, don't get use to that!!

  10. #10
    scoutt
    Guest
    WF_1 was just a name tha twas on one of my scripts. it really isn't anything.
    Troy I am uploading the script, it is in text format. just rename the txt part to cgi.
    now do you now where you perl path is or can you find out. I left it as the most common line so it should work. now when you upload it you have to do it in acsii mode and then chmod it to 755.

    I will upload your form in another post

  11. #11
    scoutt
    Guest
    ok here is your form.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Thumbs up THANKS!!! Scoutt

    I will try them first thing in the morning when I get to work! Oh Buy the way I am using IIS for a web server not UNIX is that a problem? I noticed this is UNIX #!c:/perl/bin/perl Sorry I should have told you that to begin with. I'm a newbie to this Web development stuff.

    THANKS! Again!!!!!
    TMacPherson
    MIS Systems Engineer
    [email protected]


  13. #13
    scoutt
    Guest
    it shouldn't matter. if it does change it accordinly. or it might just skip over it.

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Unhappy Cant get it to work

    It may be because of this line $mail_prog = '/usr/lib/sendmail' ; This points the the UNIX sendmail program. I am using Outlook and Exchange(which is not on the server). Hmm not sure where to go from here. I am downloading a Perl interpeter and I will try agian. I'll let you now

    -Troy
    TMacPherson
    MIS Systems Engineer
    [email protected]


  15. #15
    scoutt
    Guest
    ya, we may have to change it to asp or php. I don't know asp but php is very easy. I already have a script for php tha twill work with any form.

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Thumbs up Cool

    Can you send it to me or post it? [email protected]

    I really appreciate the time you are spending on this!!

    -Troy
    TMacPherson
    MIS Systems Engineer
    [email protected]


  17. #17
    scoutt
    Guest
    no problem, I'm here to help

    you have to change these in your action request file
    Code:
    <input type="hidden" value="[email protected]" name="recipient">
    <input type="hidden" value="action request" name="app">
    <FORM METHOD="GET" ACTION="form.php">
    I am not sure if you need the shebang line for php on IIS, I have heard that you don't need it, but I needed at my ISP server. if it shows up in the page after you submit it then chances are you won't need it.
    Attached Files Attached Files

  18. #18

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Brings up form.php

    I tried that and all I can get it to do is bring up form.php. I'm assuming I needed to change form.txt to form.php? do I still need perl? or some other intereter running to read the form.php file?
    TMacPherson
    MIS Systems Engineer
    [email protected]


  19. #19
    scoutt
    Guest
    ya I forgot to tell ya to rename it to form.php. I am not sure if IIS needs a php interpreter but you don't need perl. is it your server or your isp's?

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    North East America
    Posts
    463

    Mine

    It's My server so if need be I can install the php stuff. I just down loaded it from PHP. One thing that may be a problem is we use Exchange for a mail service instead of SMTP.
    TMacPherson
    MIS Systems Engineer
    [email protected]


  21. #21
    scoutt
    Guest
    not postivie but you can change it to send through exchange. it is in the php.ini file. it will have something in there like
    sendmail = localhost or /usr/lib/sendmail . i think you should be able to change that to your settings.

    I am at work so I can't read the ini file.

    you can read this also
    http://www.php.net/manual/en/configuration.php

Posting Permissions

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



Click Here to Expand Forum to Full Width