duandianwen1723 2011-03-14 23:22
浏览 55
已采纳

使用jQuery添加表单字段和PHP会话以记住添加的字段

I am creating a multi-paged form and now i am consulting the Stack guru's for some assistance;

On this page the user can add more input fields [type=text] onto the page

So basically there is a singular input for "CHILD NAME" then a Add button to allow the user to add more children if they have more than one.

My form allows you to go backwards and forwards, the form remembers what was input, how would i get jQuery and php to remember that the form fields were added so they are not hidden when the user re-vists the page ?

  • 写回答

2条回答 默认 最新

  • doq91130 2011-03-14 23:23
    关注

    well with adding inputs you can do:

    $('form').append('<input>',{type: 'text', name: 'input_name'})
    

    and you can save previous parts of the form data with php $_SESSIONs

    example of a form:

    in php you will get all the post (or get) values:

    $_POST = array ('name1' => 'me', 'name2' => 'you' )...
    

    and then you can save those in a session with:

    $_SESSION['lastpostedvalues'] = $_POST;
    

    or something like that.

    remember to have session_start() at the top of the php file

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

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置