doupiao9318 2019-04-21 13:37
浏览 87
已采纳

是否可以将表单中的数组作为隐藏字段传递? [重复]

This question already has an answer here:

I have a form that submits various fields to create a new child job to the parent, but certain information from the parent job needs to be passed to the new job. There are a lot of fields that need to be passed to the new job, so I am wondering if it's possible to pass an array as a hidden field to a form.

I have searched online and found different options, such as passing the array as a concatenation, but I have too many fields to pass over. $job is the array I want to pass.

<form method="post" action="##">
    <input type="hidden" name="job" value="<?php echo $job; ?>">
</form>

The error I got with the code above is "array to string conversion", which makes sense, but how do I get around it? There are many fields (probably close to 60) which need to be passed, so doing them one by one is not practical.

Any advice would be much appreciated.

</div>
  • 写回答

1条回答 默认 最新

  • dongshi4078 2019-04-21 13:44
    关注

    You can pass the id of the parent job in the hidden field, on form submit action you can get the parent id and retrieve the information of that job.

    <input type="hidden" name="parent_job_id" value="<?php echo $jobId; ?>">
    

    Make sure which index holding the id of the parent job.

    It seems $job is an array, you can not echo it, you can echo its index.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?