dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Cant get values from form?

  1. #1
    Join Date
    Jul 2013
    Posts
    89

    Cant get values from form?

    cant get the value from the form. Due to Firebug the form is submitted tho and when I delete the js it works so it has somethin to do with it. I guess i somehow have to fetch the values ($_POST) with js in the script but im not familiar with js so i havent being able to solve it.

    Code:
    $ok= $_POST['ok']; //this doesnt work
    
    if($ok== "ok" ){ 
      echo "works";
    }
    
    
    <script type="text/javascript">
        $(document).ready(function() {
            var frm = $('#form');
            frm.submit(function (ev) {
                $.ajax({
                    type: frm.attr('method'),
                    url: frm.attr('action'),
                    data: frm.serialize(),
    
                });
                ev.preventDefault();
            });
        });
    
     function submitForm2() {
            $('#form').submit();
        }
    </script>
    
    <div onclick='submitForm2();'></div>
    
    <form action='' method='post' id='form'>
            <input type="hidden" name='ok' value="ok">
    
        </form>

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,715
    try this code
    signature under construction

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles