Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    49
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Posting to a PHP page then having the current page update

    I posted in the PHP forum about this and I'm starting to think (after other pointed out) that my PHP codes may not be the culprit here.. If someone could shed the light on what I'm doing wrong it would be greatly appreciated..

    Thanks in Advance!!

    Here's what I'm trying to do:

    on (page1.php) submit a form that has 3 variables that the user inputs - these var's are sent to a seperate processing page (process.php) - but on Page 1 there is a current list of things the user already added and when they add another item I want it added to the very last line..

    Ideally, this is what I'm wanting to do: http://demo.tutorialzine.com/2010/03...l-css/demo.php

    However, I want to be able to add the values before it's added, be able to edit each variable (per id (IE: Name, Number, Description) - not just 1 object all together) and I don't want the "repositioning" feature that this has.

    Here's my JS

    Code:
    $(function() {  
      $('.error').hide();  
      $(".button").click(function() {  
        // validate and process form here  
      
        $('.error').hide();  
          var p_name = $("input#p_name").val();  
            if (p_name == "") {  
          $("label#p_name_error").show();  
          $("input#p_name").focus();  
          return false;  
        }  
            var p_desc = $("input#p_desc").val();  
            if (p_desc == "") {  
          $("label#p_desc_error").show();  
          $("input#p_desc").focus();  
          return false;  
        }  
            var p_numb = $("input#p_numb").val();  
            if (p_numb == "") {  
          $("label#p_numb_error").show();  
          $("input#p_numb").focus();  
          return false;  
        }  
      
      var p_name = $("input#p_name").val();  
      var p_desc = $("input#p_desc").val();  
      var p_numb = $("input#p_numb").val();
      //submit the form here
      var dataString=new Array(p_numb, p_name, p_desc)
    //var dataString = 'p_name='+ p_name + '&p_desc=' + p_desc + '&p_numb=' + p_numb;  
    //alert (dataString);return false;  
    $.ajax({  
      type: "POST",  
      url: "addPort.php",  
      data: dataString,  
      success: function() {  
        $('#contact_form').html("<div id='message'></div>");  
      }  
    });  
    return false;
      });  
    });
    Here's a link to my PHP Post (which has more coding listed) php and ajax submitting a form, updating a page
    Last edited by RoMa; 02-01-2011 at 03:21 AM.


 

Posting Permissions

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