简体   繁体   English

从输入字段存储值,而不发送表单

[英]Store value from input field without sending form

I need to store value from input field in form one. 我需要以形式一存储来自输入字段的值。 Reason why I need that is when I send form 2 in the same file, all filled input fields in form 1 is blank. 我需要这样做的原因是,当我在同一文件中发送表单2时,表单1中所有填充的输入字段均为空白。 My thinking is to read value from form 1 and in form 2 make hidden field with that value. 我的想法是从表格1读取值,然后在表格2中用该值隐藏字段。 When I send form 2, I can $_POST that hidden field as value in form 1. Now I use jquery: 当我发送表单2时,我可以$ _POST该隐藏字段作为表单1中的值。现在,我使用jquery:

    <script type="text/javascript">
    $('#search_field').val('<?=$value?>');
    var = $('#search_field').val();
    </script>

All works if I in that field echo $_GET value. 如果我在该字段中回显$ _GET值,则一切正常。 In some cases I need that, but if $_GET is no set, I need to fill that field by myself. 在某些情况下,我需要这样做,但是如果未设置$ _GET,则需要我自己填写该字段。 How can I store value what I filled by myself? 我该如何存储自己所拥有的价值?

First form is search form, what sends data to search engine. 第一种形式是搜索表单,它将数据发送到搜索引擎。 Second form is calendar fields, what specifies time for search results. 第二种形式是日历字段,它指定搜索结果的时间。 I have 3 choises - all, 30 days, 10 days. 我有3个选择-全部,30天,10天。 When I click 10 days, then calendar fills out automatic. 当我单击10天时,日历会自动填写。

<form>bla bla 1</form>
<form>bla bla 2</form>

No, problem. 没问题。 Depending on what you need. 根据您的需要。

And if you really have to "submit" data without submitting a form you have to use AJAX/Javascript (OR use a normal link [=GET] for that). 而且,如果您确实必须“提交”数据而不提交表单,则必须使用AJAX / Javascript(或为此使用常规链接[= GET])。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在会话中存储输入字段值,而无需提交表单 - Store input field value in session without form submit 无需提交表单即可获取输入字段的值 - Get value of input field without submitting form PHP的形式在POST的输入值字段发送数组 - php form sending array in input's value field with POST 如何在不打开表单的情况下将条形码阅读器发送的值输入表单的文本字段? - How to input a value sent from a barcode reader to a form's text field without opening the form? 如何禁用输入字段而不影响PHP表单中字段的值? - How to disable input field without affecting the value of the field in a PHP form? 从表单中的输入字段发送多个值不能在PHP中工作 - sending multiple values from input field in form not working in php 从输入字段获取值并使用ajax传递到新页面,而无需提交表单 - Get value from input field and pass to new page using ajax without submitting form JavaScript - 如何从函数传递/存储值以形成隐藏字段? - JavaScript - How to pass/store value from function to form hidden field? 如何在不提交表单的情况下从输入字段获取文件路径? - how to get file path from input field without submitting the form? php - 如何在不提交表单的情况下从输入字段中获取文本 - How to get text from input field without submiting form in php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM