<script type="text/javascript"> function enter_number(the_box) { var new_number = prompt("Enter number", ""); the_box.innerHTML = new_number; } </script> <td<?php if ($numbers[1][1] == ' ') { echo " onclick='javascript:enter_number(this);'"; } ?>> <?php echo $numbers[1][1]; ?> </td> The cell (td) above uses PHP to decide if the cell has a space or not. If it does, the PHP echoes the js and allows for input. This works fine. How do I get the variable that is typed in so that I can work on it in PHP? I'm not looking to use AJAX right now. Thanks for any help.
Yes, but how do I access (call) the variable. I'm sorry to say, but I don't know my way around js. Once I can access the var, I can submit it via a form. I'm using to check that all the numbers are present.
I don't understand what you're trying to achieve. You're using a prompt, are you trying to submit that number from the prompt to the PHP ?
Sounds like you're trying to perform some type of Ajax task, which seems like there are a lot better ways to implement the variables through PHP files and HTTPGetRequest
Ok, maybe I'm making things to difficult for no reason. I suppose the easiest way to do my check is with js, so submitting to PHP is out. Still, how do I call/access the variables? the_box.innerHTML[0], the_box.innerHTML[1], the_box.innerHTML[2], etc.?
As you don't want ajax, then you have to use some form elements. If you don't want to mess up the table with text field, use type hidden, and set action in form to your PHP file. Based on method in the form you can then read the values from e.g. <input type="text" name="the_box_1" value="1" /> like: $num = $_POST['the_box_1']; or $num = $_GET['the_box_1']; Then your code may look like: <script type="text/javascript"> function enter_number(the_box) { var new_number = prompt("Enter number", ""); the_box.innerHTML = new_number; } </script> <form action="read.php" method="post"> <td><input type="text" name="the_box_<?php echo $order ?>"<?php if ($numbers[1][1] == ' ') { echo " onclick='javascript:enter_number(this);'";} ?> value="<?php echo $numbers[1][1]; ?>" /> </td> ... <input type="submit" /> </form> Code (markup): Variable $order represents just some value that will increment for every text field, so you have unique names. Other way is to use name="the_box[]". That will be automatically parsed into array on form submit, and you can read it in PHP like $num = $_POST['the_box']; and in $num is array of all values...
Thanks for the help so far guys. Slight change of topic: How can I change a cell's value without using a form or submit button?