表单get方式提交,怎样给参数urlencode编码解决方案
表单get方式提交,怎样给参数urlencode编码
表单get方式提交,怎样给参数urlencode编码
例如:
1.php
<form method="get" action="">
请输入类型:<input type="text" name="type" />
<input type="submit" value="提交" />
</form>
在文本框中输入中文,点击提交,这时得到的url是1.php?type=中文,
我怎样才能得到1.php?type=urlencode(中文)的url呢?
------解决方案--------------------
把提交按钮的类型改变button,onclick时先编码文字,再更改文档的location.
用js控制浏览器地址的变更。
------解决方案--------------------
------解决方案--------------------
你如果非得这样,那干脆在FORM提交时进行处理
1.php
表单get方式提交,怎样给参数urlencode编码
例如:
1.php
<form method="get" action="">
请输入类型:<input type="text" name="type" />
<input type="submit" value="提交" />
</form>
在文本框中输入中文,点击提交,这时得到的url是1.php?type=中文,
我怎样才能得到1.php?type=urlencode(中文)的url呢?
------解决方案--------------------
把提交按钮的类型改变button,onclick时先编码文字,再更改文档的location.
用js控制浏览器地址的变更。
------解决方案--------------------
------解决方案--------------------
你如果非得这样,那干脆在FORM提交时进行处理
1.php
- PHP code
<script type='text/javascript'> function sub() { window.location.href='1.php?input1='+encodeURI(document.getElementByName('input1')); return false; } </script> <?php echo $input1; ?> <form name='form1' method='get' onSubmit='return sub();'> <input type='text' name='input1'> <input type='submit'>
------解决方案--------------------