Results 1 to 4 of 4
  1. #1
    dreday's Avatar
    dreday is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58

    Angry jQuery and buttons

    I have a page that loads page content using Ajax and jQuery out of MySQL. For retrieving basic pages this is fine, all loads and displays well. However, when I try to retrieve a form out of the table, jQuery doesn't recognize the controls that are loaded. I've written the function to trap the submit button and process the form with Ajax, but it seems to skip the code and submit like a normal page. Racking my brain here. Source below:

    jQuery
    Code:
    //Jquery functions for main site
    $(document).ready(function(){
        $(".navitem").mouseover(function(){
            $(this).css("background-color", "#FFFFFF");
            $(this).css("color", "#0026FF");
            $(this).css("font-weight", "bolder");
        }).mouseout(function(){
            $(this).css("background-color", "#0026FF");
            $(this).css("color", "#FFFFFF");
            $(this).css("font-weight", "");
        }).click(function(){
            var pageid;
            pageid = 'page=' + $(this).attr("id");
                $.ajax({
                    type: 'POST',
                    url: 'includes/content.php',
                    data: pageid,
                    dataType: 'text',
                    success: function(response){
                        var json = $.parseJSON(response);
                        $("div#content").html(json['content']);
                    },
                    error: function(error){
                        $("div#content").html("<h2>Page not found</h2>");
                    }
                });
            });
        $('.error').hide();
        $(".button").click(function() {
          // validate and process form here
          $('.error').hide();
            var name = $("input#name").val();
              if (name == "") {
            $("label#name_error").show();
            $("input#name").focus();
            return false;
          }
              var email = $("input#email").val();
              if (email == "") {
            $("label#email_error").show();
            $("input#email").focus();
            return false;
          }
              var phone = $("input#phone").val();
              if (phone == "") {
            $("label#phone_error").show();
            $("input#phone").focus();
            return false;
          }
          var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone;
          //alert (dataString);return false;
          $.ajax({
            type: "POST",
            url: "bin/process.php",
            data: dataString,
            success: function() {
              $('#contact_form').html("<div id='message'></div>");
              $('#message').html("<h2>Contact Form Submitted!</h2>")
              .append("<p>We will be in touch soon.</p>")
              .hide()
              .fadeIn(1500, function() {
                $('#message').append("<img id='checkmark' src='images/check.png' />");
              });
            }
          });
          return false;
        });
    });
    Form HTML loaded from table:

    Code:
    Samples page<br>
    
    
    <div id="content">
                <div id="contact_form">  
                    <form name="contact" action="">  
                      <fieldset>  
                        <label for="name" id="name_label">Name</label>  <br>
                        <input type="text" name="name" id="name" size="30" value="" class="text-input" />  <br>
                        <label class="error" for="name" id="name_error">This field is required.</label>  <br>
                        <label for="email" id="email_label">Return Email</label>  <br>
                        <input type="text" name="email" id="email" size="30" value="" class="text-input" />  <br>
                        <label class="error" for="email" id="email_error">This field is required.</label>  <br>
                        <label for="phone" id="phone_label">Return Phone</label>  <br>
                        <input type="text" name="phone" id="phone" size="30" value="" class="text-input" />  <br>
                        <label class="error" for="phone" id="phone_error">This field is required.</label>  <br>
                        <br />  
                        <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />  
                      </fieldset>  
                    </form>  
                </div>  
            </div>


    Please help!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Why have you posted in an Access forum? That isn't even VBA code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    dreday's Avatar
    dreday is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58
    Forum title:

    Misc


    PHP, MySQL, Windows and any other technical discussions unrelated to Access.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Okay, sorry, just haven't seen much 'Misc' posting that doesn't involve Access/VBA.

    Might have more luck at http://forum.jquery.com/
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 09-18-2012, 02:00 PM
  2. Radio Buttons
    By ccordner in forum Forms
    Replies: 1
    Last Post: 01-27-2012, 09:56 AM
  3. Buttons!
    By kp123 in forum Access
    Replies: 5
    Last Post: 12-08-2011, 04:22 AM
  4. Menu buttons
    By lwcollin in forum Access
    Replies: 3
    Last Post: 07-11-2011, 10:58 AM
  5. Buttons
    By dunnmel4 in forum Access
    Replies: 1
    Last Post: 04-07-2011, 12:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums