我有一个包含3个输入字段的搜索表单,它将在同一页面上返回结果。我重写了网址,使其看起来像这样:
http://www.demosite.com/search/input1/input2/input3
表单提交如下数据:
http://www.demosite.com?field1=input1&field2=input2&field3=input3
正如我在完成URL重写之前所说的那样,我只需要将表单以友好的方式提交到同一页面。
我设法找到一个带有一个输入字段的表单的解决方案
<form name="search" method="get" action="http://www.demosite.com/index.php" enctype="multipart/form-data" onsubmit="location.href='http://www.demosite.com/search/' + encodeURIComponent(this.field1.value); return false;">
但是我无法使用3个输入字段,这是我的初学者解决方案使用良好的解决方案:
<form name="search" method="get" action="http://www.demosite.com/index.php" enctype="multipart/form-data" onsubmit="location.href='http://www.demosite.com/search/' + encodeURIComponent(this.field1.value) + '/' + encodeURIComponent(this.field2.value) + '/' + encodeURIComponent(this.field3.value); return false;">