2 回答
TA贡献1842条经验 获得超21个赞
您可以通过JavaScript中的键侦听器来执行此操作
<script>
var myUrl = "<?php echo $url; ?>results/1/";
function updateAction(ele) {
var txt = ele.value; //get the user input
ele.parentElement.setAttribute("action",myUrl+txt);
}
</script>
<input onkeyup="updateAction(this);" id="search-box" name="search" size="40" type="text" placeholder="what are you looking for............"/>
TA贡献1828条经验 获得超3个赞
您的表单是通过post方法提交的。您需要从中获取搜索查询$_POST['search'],并将其分配给变量$search
<?php $search = $_POST['search'] ?>
<form action="<?php echo $url; ?>results/1/<?php $search;?>" method="post" name="search" id="searchthis" style="display:inline;">
<input id="search-box" name="search" size="40" type="text" placeholder="what are you looking for............"/>
<input id="search-btn" value="search" type="submit"/>
</form>
- 2 回答
- 0 关注
- 154 浏览
添加回答
举报