php - 方法帖子或会话
问题描述
我想将数据从表传递到字段表单这是 js 代码
<script type="text/javascript">
var y = document.getElementById("num1").innerHTML;
jQuery(document).ready(function($) {
$(".coll").on("click", function() {
window.location = '<?php echo site_url("inscription/"); ?>';
</script>
这是表格的一部分(formation.php)
<tr class='clickable-row'>
<td id="num1" class="coll">
<?php echo get_post_meta(get_the_ID(),'titre_module_'.$i,true); ?>
</td>
<td id="num2" class="coll">
<?php echo get_post_meta(get_the_ID(),'desc_module_'.$i,true); ?>
</td>
<td class="coll">
<?php echo get_post_meta(get_the_ID(),'duree_'.$i,true); ?>
</td>
<td class="coll">
<?php $date_session = wpautop(get_post_meta(get_the_ID(),'date_module_'.$i,true));
echo $date_session;
?>
</td>
<td class="coll">
<?php $date_session2 = wpautop(get_post_meta(get_the_ID(),'sess2_'.$i,true));
echo $date_session2;
?>
</td>
</tr>
这是表单的字段(inscription.php)
<div class="form-group">
<label title="Intitulé du module">Intitulé du module</label>
<input type="text" name="intlmod" class="form-control" placeholder="Intitulé du module">
</div>
所以我希望当我点击一个 TD 时,它会将我重定向到该字段已满的表单页面
解决方案
基本上,您可以使用 get 或 post 或 session 来完成,而不必使用 JS。这是使用 http get 方法和 urlencode 的示例格式。
<table>
<tr>
<td id="num1" class="coll"><a href="inscription.php?value=<?php echo urlencode(get_post_meta(get_the_ID(),'titre_module_'.$i,true)); ?>"><?php echo get_post_meta(get_the_ID(),'titre_module_'.$i,true); ?></a></td>
</tr>
</table>
在您的 inscription.php 页面中使用以下代码
<div class="form-group">
<label title="Intitulé du module">Intitulé du module</label>
<input type="text" name="intlmod" class="form-control" value="<?php echo $value = urldecode($_POST['value']); ?>" >
</div>
推荐阅读
- amazon-web-services - 如何让 Terraform 读取 AWS 凭证文件?
- linux - 如何从字面上比较'*'作为linux中的字符串
- java - Netbeans 12.0 - 从 DB 生成实体类使用 Java Date 类而不是 LocalDate
- node.js - 如何在猫鼬中分组
- angular - Angular,当其中一个组件调用服务中的特定功能时,如何更新显示在多个组件上的数据?
- mysql - MySQL多对多JSON聚合合并重复键
- gulp - Gulp 日志文件在哪里?
- huawei-mobile-services - 如何在华为应用市场中更改开发者名称?
- xml - XSLT 使用引用转换 XML
- javascript - 这个函数(可能是回调)在这段代码中做了什么?