我想根据输入值更改表单目的地。我怎样才能做到这一点?
<form id="form" method="POST" action="x.php" onSubmit="">
<input type="url" id="address" value="google.com">
<input type="submit" id="go" value="Go">
</form>
示例:当我将其设置http://google.com
为地址值时,请将此表单发送到google.com。
我使用JavaScript:如何获取文本输入字段的值?&如何通过JavaScript设置表单操作?。
所以我的结果是:
<script type="text/javascript">
function get_action(form) {
form.action = 'http://'+document.getElementById("address").value;
}
</script>
<form onsubmit="get_action(this);">
<input type="text" id="address" value="google.com">
<input type="submit" id="go" value="Go">
</form>
谢谢@Mike和@PrashantValanda:*
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句