www.webdeveloper.com
Results 1 to 6 of 6

Thread: Editable Table/Form

  1. #1
    Join Date
    Aug 2010
    Posts
    3

    Editable Table/Form

    I have created a table that allows the user to edit specific cells by clicking on them. Their new entered values set the value on the table. They then should be able to submit a form which sets several hidden inputs equal to the values in the table then passing the information to a php page to process. However, the php page doesn't output anything when it is submitted.

    This is the form layout.

    HTML Code:
    <form method="post" action="mypage.php" id="complex" name="complex">
    
    <input type="hidden" id="1x1" value="">
    ...etc.
    When the user enters all the data into the table they click on a submit button which calls a script like this...

    Code:
    function getValues()
    {
    	document.getElementById("1x1").value = document.getElementById('table').rows[3].cells[1];
    ...
    document.getElementById("complex").submit();
    NOTE: although I have the id of the cell as "1x1" it is actually the 4th row and 2nd cell of the table.

    The form is then submitted to a PHP page like such:

    PHP Code:
    <?php
    $con 
    mysql_connect("localhost","user","pass");
    if (!
    $con)
      {
      die(
    'Could not connect: ' mysql_error());
      }

    mysql_select_db("b6_6229906_main"$con);

    $
    1x1 $_POST['1x1'];

    $sql="INSERT INTO 'table' VALUES ('$1x1')";

    if(
    mysql_query($sql) === FALSE ) {
        die(
    'Error: ' mysql_error());
    }
    echo 
    "1 record added"


    mysql_close($con);
    ?>

    I know this is a javascript thread but I really don't know if the error is in the javascript or php, but no PHP error is displayed. Also, there are about 75 entries being processed not just the "1x1", I just simplified it for readability.

  2. #2
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by jnance2004 View Post
    ......I really don't know if the error is in the javascript or php, but no PHP error is displayed.......
    This statement suggests to me you did not do any testing along the way as you wrote the code.

    To me it looks like you just need to do some Basic Debugging 101 (post #1) to find the errors in your code.

    Think of debuging as character building

  3. #3
    Join Date
    Aug 2010
    Posts
    3
    I actually did alot of debugging. It took me several hours of debugging and now i receive 0 javascript errors and 0 php errors. im just getting no output on the php page. there are no loops within my code that it could be stuck in either.

  4. #4
    Join Date
    Aug 2010
    Posts
    3
    I guess what im asking is how should i go about debugging? because Im getting no client-side errors but even if I try to say echo $1x1 i get no output. So, Im wondering if im doing something wrong with retreiving table values or perhaps there is something with passing values using hidden inputs and the post method that im unaware of. I really am just not sure where to go from here because of the lack of output/errors im receiving

  5. #5
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The ids used are invalid: http://www.w3.org/TR/html401/types.html#type-name

    Form controls must have a name if you want to send data to the server.

    Always check you are receiving the expected data:
    Code:
    <?php
    foreach ( $_POST as $key => $value ) {
     print $key . " = " . $value . "<br>";
    }
    ?>
    Code:
    document.getElementById("1x1").value = document.getElementById('table').rows[3].cells[1].innerHTML
    At least 98% of internet users' DNA is identical to that of chimpanzees

  6. #6
    Join Date
    Mar 2010
    Posts
    2,803
    Quote Originally Posted by jnance2004 View Post
    I actually did alot of debugging. It took me several hours of debugging and now i receive 0 javascript errors and 0 php errors. im just getting no output on the php page. there are no loops within my code that it could be stuck in either.
    Did you check the values of the parameters being sent to the php script are actually correct before submitting them.

    And in my Basic Debugging 101 link I suggest you check the values of parameters being received by the form before you code any further.

    Have you checked the values of the parameters received by your php script?

    If you did check the parameter values received by our php script, the cause of your error would have become very obvious.

    I am not convinced you did any debugging.
    Last edited by tirna; 08-29-2010 at 02:21 AM.

Thread Information

Users Browsing this Thread

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

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
  •  
HTML5 Development Center



Recent Articles