我想要的是用户在警报输入上输入一些文本时,如下所示在php创建的数组上显示的内容: https : //imgur.com/a/tNVNAqF

到目前为止,我所做的正是这一点,除了它在整个数组上输入值,如下图所示:

https://imgur.com/a/Oe4nJi2

我的代码加上注释的解释:

popUp.php

 <html> <head> <title>Two-dimensional Arrays</title> <style> td {height: 40px;} table {width: 40%; border: 3px solid blue;} table tbody tr:nth-child(odd) { background-color: red; } table tbody tr:nth-child(even) { background-color: green; } </style> </head> <body> <!-- GETS FROM THE USER THE INPUT VALUE WHEN PRESSING THE BUTTON--> <input action="" method="get" name="button" type="button" id="inputChar" onclick="Click();"value="CLICK HERE"> <?php echo "<table border =\\"1\\" >"; for ($row=1; $row <= 10; $row++) { echo "<tr> \\n"; for ($col=1; $col <= 10; $col++) { echo "<td id='inputChar'> </td> \\n"; } echo "</tr>"; } echo "</table>"; ?> <script> // A JAVASCRIPT FUNCTION ACTIVATED WHEN CLICKING THE BUTTON WHERE THE USER INPUTS THE VALUE function Click(){ var Vvalue = prompt("Please input the value"); window.location.href = "main.php?Vvalue=" + Vvalue; } </script> </body> </html> 

main.php

 <html> <head> <title>Two-dimensional Arrays</title> <style> td {height: 40px;} table {width: 40%; border: 3px solid blue;} table tbody tr:nth-child(odd) { background-color: red; } table tbody tr:nth-child(even) { background-color: green; } </style> </head> <body> <?php $char = $_GET['Vvalue']; // GETS THE JAVASCRIPT USER INPUT VALUE FROM popUp.php echo "<table border =\\"1\\" >"; for ($row=1; $row <= 10; $row++) { echo "<tr> \\n"; for ($col=1; $col <= 10; $col++) { echo "<td id='inputChar'> .$char.</td> \\n"; } echo "</tr>"; } echo "</table>"; ?> </body> </html> 

有谁知道我们如何实现这一目标? (TLDR:我想在数组的奇数行上显示用户输入)

  ask by Costas_ translate from so

本文未有回复,本站智能推荐:

关注微信公众号