Php 当用户提交时,将一个输入值传递到输入类型隐藏值
我有一个简单的表单,如下面的代码所示。我想将Php 当用户提交时,将一个输入值传递到输入类型隐藏值,php,javascript,Php,Javascript,我有一个简单的表单,如下面的代码所示。我想将rm\u accounts文本框中提交的值附加到URL末尾的隐藏页面确认输入值。希望这是有道理的 基本上,如果用户在rm_accounts文本框中输入'123456',我希望page_confirm的值为 非常感谢您的帮助。谢谢 我首先建议您为HTML提供一些ID,如下所示: <form id="signup" method="post" action="https://go.reachmail.net/libraries/form_wiza
rm\u accounts
文本框中提交的值附加到URL末尾的隐藏页面确认
输入值。希望这是有道理的
基本上,如果用户在rm_accounts文本框中输入'123456'
,我希望page_confirm的值为
非常感谢您的帮助。谢谢 我首先建议您为HTML提供一些ID,如下所示:
<form id="signup" method="post" action="https://go.reachmail.net/libraries/form_wizard/process_subscribe.asp" >
<input type='text' name='rm_accounts' id='rm_accounts' value='' />
<input type="hidden" name="page_confirm" id="page_confirm" value="http://www.mywebsite.com/index.php?rm_accounts=">
<input type="submit" name="Submit" value="Submit" >
</form>
使用Jquery
focusout
事件更新隐藏字段值
当用户输入12345并将焦点放在文本框外或单击submit(或anywhere)时,将执行以下代码并更新隐藏字段的值
$('input[type=text]').focusout(function(){
$('input[type=hidden]').val("http://www.mywebsite.com/index.php?rm_accounts="+$('input[type=text]').val());
console.log($('input[type=hidden]').val());
});
或在“提交”按钮中单击
$('input[type=submit]').click(function(){
$('input[type=hidden]').val("http://www.mywebsite.com/index.php?rm_accounts="+$('input[type=text]').val());
console.log($('input[type=hidden]').val());
});
工作中间链路
您是否关心是使用jquery还是直接使用javascript?我查看了JSFIDLE链接,这对警报很有意义,但如何将值输入到“page\u confirm”隐藏输入中?基本上,我需要的html结束像。。。我的jQuery技能很低,所以任何手都很受欢迎。该值已分配给该隐藏输入..这就是为什么它会显示在警报中..如果发现答案有用,请投票并接受作为答案以感谢帮助看起来您正在按类型识别表单元素。例如“输入[type=text]”和“输入[type=hidden]”。有没有办法通过名字来识别他们?我在页面上有几个文本输入和隐藏字段。请参阅更新的js fiddle,了解如何按名称选择输入和隐藏字段
$('input[type=text]').focusout(function(){
$('input[type=hidden]').val("http://www.mywebsite.com/index.php?rm_accounts="+$('input[type=text]').val());
console.log($('input[type=hidden]').val());
});
$('input[type=submit]').click(function(){
$('input[type=hidden]').val("http://www.mywebsite.com/index.php?rm_accounts="+$('input[type=text]').val());
console.log($('input[type=hidden]').val());
});