jQuery to PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear List -

I am totally stumped by this one....

I have a PHP program which will generate a chess board with a form in the program. I wish to fill the form by clicking one of the squares in the chess board. I am trying to use jQuery and Aja to do this. The Ajax call works, but the value never gets into the form.

Help and advice please.

Thanks.

Ethan


Here are some code snippets

<?php
$results = array(array("Br", "Bn", "Bb", "Bq", "Bk", "Bb", "Bn", "Br"),array("Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp", "Bp"), array("", "", "", "", "", "", "", ""),array("", "", "", "", "", "", "", ""),array("", "", "", "", "", "", "", ""), array("", "", "", "", "", "", "", ""),array("Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp", "Wp"), array("Wr", "Wn", "Wb", "Wq", "Wk", "Wb", "Wn", "Wr"));



?>
<!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"; xml:lang="en">


        <head>
                <title>Jquery Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <link type="text/css" href="jq.css" rel="stylesheet" />
<link type="text/css" href="jquery-ui-1.8.9.custom.css" rel="stylesheet" />
        </head>
                <body>
                        <div id="main">
                        <fieldset  id="main_fieldset">
                                <table  cellspacing="100">
                                        <tbody >
                                                <tr>
<td class="b1">8</td><td class="d1" id="a8"><?php echo $results[0][0];?> </td><td class="a1" id="b8" ><?php echo $results[0][1];?> </td><td class="d1" id="c8"> <?php echo $results[0][2];?> </td><td class="a1" id="d8"> <?php echo $results[0][3];?> </td><td class="d1" id="e8"><?php echo $results[0][4];?> </td><td class="a1" id="f8"> <?php echo $results[0][5];?> </td> <td class="d1" id="g8"> <?php echo $results[0][6];?> </td><td class="a1" id="h8"> <?php echo $results[0][7];?> </td>
                                                </tr>

<snip>
:
<script type="text/javascript" src="jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="jquery-ui-1.8.9.custom.min.js" ></script>


<script type="text/javascript">
$(document).ready(function(){
                $('.a1').dblclick(function() {
                $(this).css("background-color","blue");
                move_from = $(this).attr("id");
                        $.ajax({
                        type: "POST",
                        url: "jq_test.php",
                        data: 'move_from',
                        dataType: "text",
                        success: function(){
                        alert( "Yippie " );
                        }
                });
        });     });
</script>
<?php
                                if(isset($_POST))
                                {
echo "this is the variable ";echo $_POST['move_from'];
                                        var_dump($_GET);
                                        var_dump($_POST);
                                }


var_dump($_POST);
var_dump($_REQUEST);
?>
<snip>

<?php
   echo <<<HTML
                        <form method="post" action="jq_test.php">
Move From<input type="text" name="move_from"> </input><br /><br /> Move To <input type="text" name="move_to"></input><br /><br /> <input type="submit" value="Enter Move"></input>

                        </form>
HTML;
?>

        </body>

</html>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux