Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 20
  1. #1
    Senior Member Tyler Smith's Avatar
    Join Date
    Oct 2011
    Posts
    115
    Member #
    29767
    Liked
    7 times
    Hello all,

    I have made progress in developing my tool for collecting e-mails for my website at worldreviewgroup.com, but before I continue onward with this seemingly strange path, I want to ensure this is a proper way to go about this. It begins with the original submission of an e-mail address at the home page in the bottom right corner. That form has an action setting to go to a new page called showwindow.php. This page contains all of the original markup- the only new thing being the 2nd form being displayed, which collects an e-mail address (for confirming it's the same submission), their name, their age range, & their country. Once the submit input has been clicked, the script will attempt to write the supplied info to a database using PDO, and upon its success, the page will either say "Success! Thanks for signing up." or an error like "You entered a different e-mail address than the first one." or "Error connecting to database. Try again later." Now, to display these messages, the only way I know how to do would be to do the same thing as with showwindow.php, which contains all the original home page markup with just the extra form markup. So, say the success file would be "submissionsuccess.php" and the failure file "submissionfailure.php". That leads to a whole new question seeing as I would need extra logic in this code to determine which file to direct to pending the form's successful entry or failure.

    There simply has to be a more efficient way to do this without loading a whole range of different files, is there?

    These are my visual goals.
    Like in websites I've seen all too often, I am attempting to use CSS on showwindow.php to "gray out" all the original home page markup, rendering it inactive. Maybe I should also learn how that markup can literally be made inactive, so it doesn't cause any accessibility issues for the user. This will be a new thread in the CSS/HTML section eventually (I'm having trouble doing this), but for now I have to figure out how to fill these empty holes I have for my programming logic/strategy. Is there a good example someone can recommend so I see how they have implemented this type of form?

    I'd like to leave this open to any jQuery animation I may want to implement in the future, if possible, without having to use Flash. Maybe that's not possible in forms like this.

    The code thus far:

    index.php:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="Description" content="Curious about a product before you buy it? Come here for reviews on today's hot products! Some of our categories include home business, dating, consumer electronics, and many others." />
        <meta name="Keywords" content="product review site, review article database, World review group, product reviews online, product articles, online product and service reviews" />
        <meta http-equiv="Content-Language" content="en" />
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
        <link href="style/main.css" rel="stylesheet" type="text/css" media="screen,projection,tv" />
        <link href="style/dropdownmenus.css" rel="stylesheet" type="text/css" media="screen" />
        <title>World Review Group- Product Articles</title>
    </head>
    <body>
    <!-- begin container -->
    <div id="container">
    <!-- begin middle div -->
      <div id="middle">
      <!--header with image -->
        <h1>World Review Group<span></span></h1>
        <div id="body">

          <!-- SEE WEBSITE FOR HTML CONTENT -->
     
          <form id="emailbox" name="form1" method="post" action="showwindow.php">
            <div>
              <input type="text" name="go" id="go" value="your e-mail" onclick="input_focus(this)"  onblur="input_reset(this)" maxlength="60"/>
              <input type="submit" value="Join" onclick="postEmail()" />
            </div>
          </form>
          <?php
          
    //this section is for the e-mail box scripting to begin
          
    class PassEmail
          
    {
              public function 
    postEmail()
              {
                  include 
    'Scripts/finalactions.php';
                  
    $error = new FinalActions;
                  if (isset(
    $_POST["go"])){
                      
    $email $_POST["go"];
                    if (
    isItAValidEmail($email))
                       return 
    $email;
                    else
                        
    $error -> invalidEntry();
                  } else {
                    
    $error -> invalidEntry();
                  }
              }

            public function 
    isItAValidEmail($email)
            {
                if(!
    filter_var($emailFILTER_VALIDATE_EMAIL)){                                                  return false;
                } else {
                  return 
    true;
                }
            }
          }
          
    //end e-mail box scripting section
          
    ?>
          </div>
          <div id="rightsideend">&nbsp;</div>
      </div>
      <!-- end side windows -->
    </div><!-- end container -->
    <script type="text/javascript" src="Scripts/emailbox.js"></script>
    </body>
    </html>
    showwindow.php
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
           <link href="style/main.css" rel="stylesheet" type="text/css" media="screen, projection, tv" />
        <link href="style/emailsubmit.css" rel="stylesheet" type="text/css" media="screen, projection, tv" />
        <link href="style/dropdownmenus.css" rel="stylesheet" type="text/css" media="screen, projection, tv" />
        <title>Join the Mailing List at World Review Group!</title>
    </head>
        <body>
        <!-- begin container -->
    <div id="graymask">
    <div id="container">
    <!-- begin middle div -->

    <!-- SAME HTML CONTENT HERE -->

          <div id="rightsideend">&nbsp;</div>
      </div><!-- end gray mask -->
      </div><!-- end side windows -->
    </div><!-- end container -->
            <div id="formsubmit">
                        <form name="form2" id="form2" method="post" action="postsubmission.php">
                          <label for="confirmemail">Confirm your e-mail:<span>*</span></label>          
                          <input type="text" name="confirmemail" id="confirmemail" value="" maxlength="60"/><br />
                          <label for="name">Enter your name:<span>*</span></label>
                          <input type="text" name="name" id="name" value="" maxlength="60" /><br />
                          <label for="age">Select your age range:</label>
                          <select name="age" id="age">
                              <option selected="selected">18&ndash;35</option>
                            <option>36&ndash;55</option>
                            <option>55+</option>
                            <option>17 or younger</option>
                          </select><br />
                          <label for="country">Select your country:<span>*</span></label>
                          <select name="country" id="country">
                                 <option selected="selected">United States</option>
                                 <option>United Kingdom</option>
                                 <option>Canada</option>
                                 <option>Australia</option>
                                 <option>Russia</option>
                                 <option>Brazil</option>
                                 <option>Somewhere else</option>
                           </select><br />
                           <input type="submit" value="Sign Me Up!" onclick="checkEmail()"/>
                        </form>
    <?php
        
    class FormProcess
        
    {
            public function 
    getEmail()
            {
                include 
    'index.php';
                
    $emailPasser = new PassEmail;
                
    $origEmail $emailPasser -> postEmail();
                return 
    $origEmail;
            }
            
            public function 
    checkEmail()
            {
                include 
    'Scripts/finalactions.php';
                
    $error = new FinalActions;
                
    $origEmail getEmail();
                
    $confirmEmail $_POST["confirmemail"];
                if (
    $origEmail == $confirmEmail){
                    if (isset(
    $_POST["name"])){
                        
    $name $_POST["name"];
                        
    $age $_POST["age"];
                        
    $country $_POST["country"];
                        include 
    'Scripts/categoryfinder.php';
                        
    $categoryFinder = new CategoryFinder;
                        
    $category $categoryFinder -> getCategory();
                        
                        include 
    'Scripts/databasewriter.php';
                        
    $dbWriter = new DatabaseWriter;
                        
    $dbWriter -> writeUserToDatabase();
                    } else {
                        
    $error -> invalidEntry();
                    }
                } else {
                    
    $error -> invalidEntry();
                }
            }
        }
    ?>
            </div>              
        </body>
    </html>
    I'm gonna go see if I can find a good example of a dynamic PHP form that performs some similar tasks, with the visual effect that I'm looking to do- that "grayed out" effect.

    After all this, I'll need to start learning how to send e-mails in PHP as this is another facet in this project.

  2.  

  3. #2
    Senior Member Tyler Smith's Avatar
    Join Date
    Oct 2011
    Posts
    115
    Member #
    29767
    Liked
    7 times
    databasewriter.php
    PHP Code:
    <?php
        
    class DatabaseWriter
        
    {
            public function 
    writeUserToDatabase($email $name $age $country $category)
            {
                
    $connection = new PDO(
    'mysql:host=worldreviewgroupcom.***********.com;dbname=*****' "***username***" "***password***");
            if (!
    $connection){
                die(
    'Could not connect.');
           }
                
    $statement $connection -> prepare("INSERT INTO emailcollection (email, name, age, country, category) VALUES (:email, :name, :age, :country, :category)");
                
    $statement -> bindParam(':email'$email);
                
    $statement -> bindParam(':name'$name);
                
    $statement -> bindParam(':age'$age);
                
    $statement -> bindParam(':country'$country);
                
    $statement -> bindParam(':category'$category);
                
    $statement -> execute();
                
                
    $connection NULL;
            }
        }
    ?>
    categoryfinder.php
    PHP Code:
    <?php
        
    class CategoryFinder
        
    {
            public function 
    getCategory()
            {
                
    $currentURL$_SERVER['PHP_SELF'];
                if (
    preg_match($currentURL"index"))
                    return 
    "Home Page";
                elseif (
    preg_match($currentURL"health"))
                    return 
    "Health";
                elseif (
    preg_match($currentURL"insurance"))
                    return 
    "Insurance";
                elseif (
    preg_match($currentURL"general"))
                    return 
    "General";
                elseif (
    preg_match($currentURL"dating"))
                    return 
    "Dating";
                elseif (
    preg_match($currentURL"education"))
                    return 
    "Education";
                elseif (
    preg_match($currentURL"legal"))
                    return 
    "Legal";
                elseif (
    preg_match($currentURL"startyour"))
                    return 
    "Business Opportunities";
                elseif (
    preg_match($currentURL"business"))
                    return 
    "Business Services";
            }
        }
    ?>
    finalactions.php
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
        <body>
        <div id="active"><p id="error">You didn&apos;t enter a valid email, silly!</p><input type="submit" value="Go Back"     onclick="goBack()"></div>
        <?php
            
    class FinalActions
            
    {
                public function 
    invalidEntry()
                {
                
                }
                private function 
    goBack()
                {
                    
    header();
                }
            }
        
    ?>
        </body>
    </html>
    emailsubmit.css style sheet linked to showwindow.php
    Code:
    @charset "utf-8";
    /* CSS Document for the E-mail Submission Form */
    body{
        background:url("bg2gray.jpg");
    }
    
    #graymask{
        height:1000px;
        width:1360px;
        background:url("graymask.gif");
        opacity:40;
        filter:alpha(opacity=40);
        z-index:800;
    }
    
    #formsubmit{
        background:url("emailsubmission.gif") no-repeat scroll 50% 0 transparent;
        width:360px;
        height:300px;
    }
    #form2{
        padding-top:60px;
        text-align:left;
        z-index:999;
    }
    #form2 span{
        color:red;
    }

  4. #3
    Member
    Join Date
    Nov 2012
    Location
    Tampa. FL
    Posts
    59
    Member #
    33844
    Liked
    21 times
    I normally use jquery and AJAX to accomplish this. Rather than having several pages of php that you need to go to, you can have one process.php with conditional statements that will echo out the proper html based on what just happened.
    Then, on you form page, have a content div to show the results.
    Then use jquery to .post() the form which is .serialize() to make it the proper format.
    use the return function of .post() to .load() the html that it gets from process.php into the content div.

    This allows you to have one page that the user remains on while all of your program logic and database actions are happening. Plus, it reduces the amount of files you have to contend with.
    Tyler Smith likes this.
    Freelance Web Developer

  5. #4
    Senior Member Tyler Smith's Avatar
    Join Date
    Oct 2011
    Posts
    115
    Member #
    29767
    Liked
    7 times
    Okay, I have read and studied your reply carefully.

    My main goal, or desire, in this is to keep the user on one page through this process.

    Maybe I will require JS or jQuery or AJAX, but I'm just remembering every time I ask a question about JavaScript, I'm discouraged from using it because "the user may have JavaScript turned off".

    I have been trying to learn how to load & display the contents of another HTML/PHP file in the same PHP file I have as my home page, index.php, but I have had no such luck. I tried the readfile() and file_get_contents() methods with no success. PHP may not be a good choice for displaying extra HTML markup.

    Here's what I tried:

    First form HTML:
    HTML Code:
    <form id="emailbox" name="form1" method="post" action="?">
            <div>
              <input type="text" name="go" id="go" value="your e-mail" onclick="input_focus(this)"  onblur="input_reset(this)" maxlength="60"/>
              <input type="submit" value="Join" onclick="seeWhatHappened()" />
            </div>
          </form>
    index.php excerpt, which contains the conditional statements to handle the original e-mail submission:
    PHP Code:
    function seeWhatHappened()
              {
                  include 
    'Scripts/finalactions.php';
                  
    $error = new FinalActions;
                              
    //see if the user actually input a value
                  
    if (isset($_POST["go"])){
                      
    $email $_POST["go"];
                                    
    //check the input for e-mail address validity
                    
    if (isItAValidEmail($email)){
                                            
    //SHOW THE CONFIRMATION FORM - this is the area I'm currently focusing on.
                                            //Either PHP has real shortcomings here and I need JavaScript, or I have done something incorrectly.
                        
    $confirmForm readfile("showwindow.php");
                        echo 
    $confirmForm;
                    } else
                        
    $error -> invalidEntry();
                  }
                  else
                      
    $error -> invalidEntry();
              } 
    showwindow.php currently has the following inside of it:
    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
           <link href="style/main.css" rel="stylesheet" type="text/css" media="screen, projection, tv" />
        <link href="style/emailsubmit.css" rel="stylesheet" type="text/css" media="screen, projection, tv" />
        <link href="style/dropdownmenus.css" rel="stylesheet" type="text/css" media="screen, projection, tv" />
        <title>Join the Mailing List at World Review Group!</title>
    </head>
        <body>
            <div id="formsubmit">
                        <form name="form2" id="form2" method="post" action="postsubmission.php">
                          <label for="confirmemail">Confirm your e-mail:<span>*</span></label>          
                          <input type="text" name="confirmemail" id="confirmemail" value="" maxlength="60"/><br />
                          <label for="name">Enter your name:<span>*</span></label>
                          <input type="text" name="name" id="name" value="" maxlength="60" /><br />
                          <label for="age">Select your age range:</label>
                          <select name="age" id="age">
                              <option selected="selected">18&ndash;35</option>
                            <option>36&ndash;55</option>
                            <option>55+</option>
                            <option>17 or younger</option>
                          </select><br />
                          <label for="country">Select your country:<span>*</span></label>
                          <select name="country" id="country">
                                 <option selected="selected">United States</option>
                                 <option>United Kingdom</option>
                                 <option>Canada</option>
                                 <option>Australia</option>
                                 <option>Russia</option>
                                 <option>Brazil</option>
                                 <option>Somewhere else</option>
                           </select><br />
                           <input type="submit" value="Sign Me Up!" onclick="checkEmail()"/>
                        </form>
    <?php
        
    class FormProcess
        
    {
            public function 
    getEmail()
            {
                include 
    'index.php';
                
    $emailPasser = new PassEmail;
                
    $origEmail $emailPasser -> postEmail();
                return 
    $origEmail;
            }
            
            public function 
    checkEmail()
            {
                include 
    'Scripts/finalactions.php';
                
    $error = new FinalActions;
                
    $origEmail getEmail();
                
    $confirmEmail $_POST["confirmemail"];
                if (
    $origEmail == $confirmEmail){
                    if (isset(
    $_POST["name"])){
                        
    $name $_POST["name"];
                        
    $age $_POST["age"];
                        
    $country $_POST["country"];
                        include 
    'Scripts/categoryfinder.php';
                        
    $categoryFinder = new CategoryFinder;
                        
    $category $categoryFinder -> getCategory();
                        
                        include 
    'Scripts/databasewriter.php';
                        
    $dbWriter = new DatabaseWriter;
                        
    $dbWriter -> writeUserToDatabase();
                    } else {
                        
    $error -> invalidEntry();
                    }
                } else {
                    
    $error -> invalidEntry();
                }
            }
        }
    ?>
            </div>              
        </body>
    </html>
    I don't really mind the page refresh if I end up using PHP only (since it's a server-side language), but it is nifty that JS can just load/show the next step without refresh (client-side code).

    I'M REALLY STUCK!

  6. #5
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    in ASP i would use Case Select statements to call the different sections into the same page.

    not sure how that's done in PHP, maybe the "switch" statement can be used for this ? ( I'm just starting to dig into PHP so I'm still learning too )

    one of my applications has a page that has over 5000 lines of code, but it has over 50 different case select statements so only the portion of the code that is needed is called based on the variables being passed within the links ie: mypage.asp?action=save or mypage.asp?action=edit_save

    Sure one of the PHP gurus here can help

  7. #6
    Member
    Join Date
    Nov 2012
    Location
    Tampa. FL
    Posts
    59
    Member #
    33844
    Liked
    21 times
    As Webzarus said, you could do this with just php and a switch statement:
    PHP Code:
    $action $_GET['action'];
    switch (
    $action) {
        case 
    "firstStep":
            include 
    "first_step.php";
            break;
        case 
    "secondStep":
            include 
    "second_step.php";
            break;

    You could place this switch statement in the index file where you want the html to change based on the action. What this would do is load the appropriate php file based on the action selected. Then inside your first_step.php page you could just process the post data and create a form with an action method that goes to the index page and add the query string ?action=secondStep to load the second_step.php file.

    The problem is that each step will reload the entire page anyway. That's where jQuery and AJAX come in handy, they avoid a complete page refresh and allow you to just update one element in the DOM.
    Freelance Web Developer

  8. #7
    Senior Member Tyler Smith's Avatar
    Join Date
    Oct 2011
    Posts
    115
    Member #
    29767
    Liked
    7 times
    So, I've put in a jQuery/Ajax function to process the e-mail. I'm not quite sure how I'll use it to display the 2nd form for collecting the rest of the data (name, age range, country, etc.).

    This is that code, which includes the post and serialize as recommended.
    Code:
    $(function(){
        $("#origemailform").submit(function(){
            dataString = $("#origemailform").serialize();
    
            $.ajax({
            type: "POST",
            url: "process_form.cfm",
            data: dataString,
            dataType: "json",
            success: function(data) {
    
                if(data.email_check == "invalid"){
                    $("#message_ajax").html("<div id='successorfailure'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>");
                } else {
                    $("#message_ajax").html("<div class='confirmform'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
                }
    
            }
    
            });
    
            return false;          
    
        });
    });
    The HTML content of that #successorfailure div will change content, depending on whether the data entered was successful or not. I was writing some JavaScript that would just change the left and right values to display the content in its rightful position (since I have used absolute positioning for the remaining form content). I'll need to come up with something similar to process the data submitted in the 2nd form.

    Is it possible to call a jQuery/JavaScript function from this AJAX snippet to change the positioning and change the success/failure message content as well?

    I'm going to post the rest of my code in another reply in a moment, so you have a better feel of where I'm headed.

  9. #8
    Senior Member Tyler Smith's Avatar
    Join Date
    Oct 2011
    Posts
    115
    Member #
    29767
    Liked
    7 times
    I don't think that AJAX code is going to do what I need it to do as far as calling the PHP code I have prepared in my index.php file. I am befuddled how to do that in AJAX (brand SPANKIN' new to it).

    Here's my form code, etc.
    PHP Code:
    <form id="emailbox" name="form1" method="post" action="?">
            <div>
              <input type="text" name="go" id="go" value="your e-mail" onclick="input_focus(this)"  onblur="input_reset(this)" maxlength="60"/>
              <input type="submit" value="Join" onclick="processor()" id="origemailform" />
            </div>
          </form>
        </div>
        <div id="rightsideend">&nbsp;</div>
      </div>
      <!-- end side windows -->
      <div id="confirmform">
        <form name="form2" id="submissionform" method="post" action="?">
        <div>
          <label for="confirmemail" class="fixedwidth">Confirm your e-mail:<span>*</span></label>
          <input type="text" name="confirmemail" class="fixedwidth" value="" maxlength="60" class="inputwidth"/>
        </div>
        <div>
          <label for="name" class="fixedwidth">Enter your name:<span>*</span></label>
          <input type="text" name="name" class="fixedwidth" value="" maxlength="60" class="inputwidth"/>
        </div>
        <div>
          <label for="age" class="fixedwidth">Select your age range:</label>
          <select name="age" class="inputwidth">
            <option selected="selected">18&ndash;35</option>
            <option>36&ndash;55</option>
            <option>55+</option>
            <option>17 or younger</option>
          </select>
        </div>
        <div>
          <label for="country" class="fixedwidth">Select your country:<span>*</span></label>
          <select name="country" class="inputwidth">
              <option selected="selected">Select Country</option>
              <option>United States</option>
              <option>United Kingdom</option>
              <option>Canada</option>
              <option>Australia</option>
              <option>Russia</option>
              <option>Brazil</option>
              <option>Somewhere else</option>
          </select>
        </div>
        <p id="errormessage">You didn&apos;t enter the same e-mail address!</p>
          <input type="submit" value="Sign Me Up!" class="formsubmitbutton" onclick="checkSubmission()"/>
          <input type="submit" value="Cancel" class="formsubmitbutton" onclick="backToHomePage()"/>
        </form>
      </div>
      <div id="successorfailure">
          <h4>Submission Failure</h4>
          <p id="postsubmissionmessage">Your submission has failed.</p>
      </div>
    </div><!-- end container -->
    <?php
        
    class ProcessEmail
        
    {
            function 
    processor()
            {
                if (isset(
    $_POST['go']))
                {
                    
    $email $_POST['go'];
                    if (
    isItAValidEmail($email))
                    {
                        
    $showFormScript '<script type="text/javascript">showForm();</script>';
                        echo 
    $showFormScript;
                    } else {
                        
    $enteredInvalidOrigEmail '<script type="text/javascript">enteredInvalidOrigEmail();</script>';
                        echo 
    $enteredInvalidOrigEmail;
                    }
                } else {

                }
            }

            public function 
    isItAValidEmail($email)
            {
                if (
    filter_var($emailFILTER_VALIDATE_EMAIL))
                    return 
    true;
                else
                    return 
    false;
            }

            public function 
    checkSubmission()
            {
                if (
    $_POST['country'] != "Select Country")
                {
                    if (isset(
    $_POST['confirmemail']) && isset($_POST['name']))
                    {
                        
    $origEmail $_POST['go'];
                        
    $confirmEmail $_POST['confirmemail'];
                        if (
    $origEmail == $confirmEmail)
                        {
                            
    $name htmlspecialchars($_POST['name']);
                            
    $ageRange $_POST['age'];
                            
    $country $_POST['country'];

                            include 
    'Scripts/databasewriter.php';
                            
    $dbWriter = new DatabaseWriter;
                            
    $dbWriter -> writeUserToDatabase($confirmEmail$name$ageRange$country$category);
                        }
                    } else {
                    }
                } else {
                }
            }
        }
    ?>
    <script type="text/javascript" src="Scripts/jQuery.js"></script>
    <script type="text/javascript" src="Scripts/emailbox.js"></script>
    <script type="text/javascript" src="Scripts/emailerrorhandler.js"></script>
    JavaScript
    Code:
    //emailbox.js
    function input_focus(obj){
        if ( obj.value == obj.defaultValue ){
            obj.value = ""
        }
    }
    
    function input_reset(obj){
        obj.value = obj.defaultValue;
    }
    
    function documentChanger()
    {
        document.title = "Sign Up for the Mailing List at World Review Group.";
        showForm("confirmform", 492)
    }
    
    function showForm(objectID, value)
    {
        document.getElementById(objectID).setAttribute("style", "right:" + Value.toString() + "px");
    }
    
    function backToHomePage()
    {
        document.getElementById("confirmform").setAttribute("style", "right:9999em");
    }
    
    //emailerrorhandler.js
    
    // JavaScript for E-mail Input Error Handling
    
    var timeout;
    
    function enteredInvalidOrigEmail()
    {
    var errorMsg = document.getElementById("postsubmissionmessage");
    errorMsg.innerHTML = "That's not a real e-mail address!";
    var submissionHeader = document.getElementsByTagName("h4");
    submissionHeader.innerHTML = "Submission Failure";
    submissionHeader.style.textShadow = "1px 1px 1px #CC0000";
    document.getElementById("successorfailure").setAttribute("style", "left:508px");
    timeout = setTimeout(moveSuccessOrFailureDiv(), 1000)
    }
    
    function moveSuccessOrFailureDiv()
    {
    document.getElementById("successorfailure").setAttribute("style", "left:9999em");
    clearTimeout(timeout);
    }
     
    $(function(){
    $("#origemailform").submit(function(){
    dataString = $("#origemailform").serialize();
    
    $.ajax({
    type: "POST",
    url: "process_form.cfm",
    data: dataString,
    dataType: "json",
    success: function(data) {
    
    if(data.email_check == "invalid"){
    $("#message_ajax").html("<div id='successorfailure'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>");
    } else {
    $("#message_ajax").html("<div class='confirmform'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
    }
    
    }
    
    });
    
    return false;
    
    });
    });
    Thank you very much for your help. This is very difficult to get a handle on, but I'm confident that I'm catching on and learning new skills.

  10. #9
    Member
    Join Date
    Nov 2012
    Location
    Tampa. FL
    Posts
    59
    Member #
    33844
    Liked
    21 times
    Quote Originally Posted by Tyler Smith, post: 246920
    Is it possible to call a jQuery/JavaScript function from this AJAX snippet to change the positioning and change the success/failure message content as well?
    Use the jQuery .css() function.
    http://api.jquery.com/css/
    Tyler Smith likes this.
    Freelance Web Developer

  11. #10
    Member
    Join Date
    Nov 2012
    Location
    Tampa. FL
    Posts
    59
    Member #
    33844
    Liked
    21 times
    Quote Originally Posted by Tyler Smith, post: 246921
    I don't think that AJAX code is going to do what I need it to do as far as calling the PHP code I have prepared in my index.php file. I am befuddled how to do that in AJAX (brand SPANKIN' new to it).
    You will need to place your code in a separate page and call is using .post()
    I see that you are using .ajax() which is the longer version. Take a look at the .post() documentation in the link provided.
    At the bottom there is an example of using .post() with a form.
    http://api.jquery.com/jQuery.post/
    Tyler Smith likes this.
    Freelance Web Developer


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com