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 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助