[英]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.