douzhanlie9209 2013-12-21 20:13
浏览 23
已采纳

PHP:<a>标签的帖子名称,然后在链接页面上使用

so basically lets say I have a page called page-with-links.php:


<ul>
    <li><a href="page-with-checkboxes.php" name="blue">Blue</a></li>
    <li><a href="page-with-checkboxes.php" name="red">Red</a></li>
    <li><a href="page-with-checkboxes.php" name="green">Green</a></li>
    <li><a href="page-with-checkboxes.php" name="yellow">Yellow</a></li>
    <li><a href="page-with-checkboxes.php" name="orange">Orange</a></li>
</ul>


and a page called page-with-checkboxes.php:

<h3>You selected:</h3>

<form>
    <input type="checkbox" name="blue" />
    <label for="blue"> Blue</label><br>

    input type="checkbox" name="red" />
    <label for="red"> Red</label><br>

    input type="checkbox" name="green" />
    <label for="green"> Green</label><br>

    <input type="checkbox" name="yellow" />
    <label for="yellow"> Yellow</label><br>

    <input type="checkbox" name="orange" />
    <label for="orange"> Orange</label><br>
</form>



I would like to be able to use the name value of the <a> tag to check the related box on the next page.

For example, if the user clicks 'green' on page-with-links.php, I would like the checkbox with name="green" to be checked when page-with-checkboxes.php loads.

I hope I've been clear enough. Thanks in advance to anyone who can help!

  • 写回答

3条回答 默认 最新

  • douwei3172 2013-12-21 20:34
    关注

    write line of code on your page page-with-links.php

    <ul> <li> <a href="page-with-checkboxes.php?value=blue" name="blue">Blue</a> </li> <li> <a href="page-with-checkboxes.php?value=red" name="red">Red</a></li> <li> <a href="page-with-checkboxes.php?value=green" name="green">Green</a></li> <li> <a href="page-with-checkboxes.php?value=yellow" name="yellow">Yellow</a></li> <li> <a href="page-with-checkboxes.php?value=orange" name="orange">Orange</a></li> </ul>

    and write follow line of code on page called page-with-checkboxes.php:

    <input type="checkbox" name="blue" <?php echo $_GET['value']=='blue'?'checked':''; /> <label for="blue"> Blue</label><br> <input type="checkbox" name="red" <?php echo $_GET['value']=='red'?'checked':''; /> <label for="red"> Red</label><br> <input type="checkbox" name="green" <?php echo $_GET['value']=='green'?'checked':''; /> <label for="green"> Green</label><br> <input type="checkbox" name="yellow" <?php echo $_GET['value']=='yellow'?'checked':''; /> <label for="yellow"> Yellow</label><br> <input type="checkbox" name="orange" <?php echo $_GET['value']=='orange'?'checked':''; /> <label for="orange"> Orange</label>

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端