ammm...I have this code

<table border="1" name="myTable" id="myTable">
<?php 
$nRow = $_GET['rowLength'];
$nColumn = 7;
for($i=0;$i<$nRow;$i++){
    echo "<TR>";
    for($i=0;$i<$nColumn;$i++){
        echo "<TD><INPUT TYPE='text' NAME='' VALUE=''/></TD>";
    }
    echo "</TR>";
}?>
</table>

now, I'm trying to pass js variable to php variable on the same page....
but I'm having this error: Undefined index: rowLength

...I'm using $_GET to get the variable rowLength from js...
...thank you in advance...

Hi,

Can you rewrite your js function so that the only thing left is to call that function. If so, you can do it like my example below. Not a big one, but that's how you make the php call for the output of the js function. unless, you want to wrap the entire js as php variable, then the possiblility is a little bit brighter. However, passing it in the script like your script above will not do it, because PHP is parse on the server side, while js is interacting on the client side.

<?php
echo "hello! I am echoed by php <br/>";
?>

<html>
<head>
<script type="text/javascript">
function displayDate()
{
document.getElementById("out").innerHTML=Date();
}
</script>
</head>
<body>

<p>Javascript ouput delivered by php </p>
<p id="out">Echoed JS function shows here.</p>

<button type="button" onclick="<?php echo 'displayDate()';?>">Clikc Me</button>

</body>
</html> 

thank you for the reply veedeoo...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.