<input type="text" name="ididid" value="请输入想找的宝贝"> <a href="http://127.0.0.1:8000/goodsdetails/3/">在html中,如何将ididid附在http://127.0.0.1:8000/goodsdetails/3/后面
时间: 2023-06-20 15:07:45 浏览: 30
可以使用表单来实现这个功能,代码如下:
```html
<form action="http://127.0.0.1:8000/goodsdetails/3/" method="get">
<input type="text" name="ididid" value="请输入想找的宝贝">
<input type="submit" value="查找">
</form>
```
这样,用户在输入框中输入想找的宝贝,点击“查找”按钮后,就会跳转到类似于"http://127.0.0.1:8000/goodsdetails/3/?ididid=xxx"的页面,其中xxx就是用户输入的内容。
相关问题
<div class="input" style="margin-top: 10px"> <input type="" name="" value="请输入想找的宝贝"> <a href="http://127.0.0.1:8000/goodsdetails/"> <img src="/static/1_061.png"></a> </div>使value更改后的内容能够附在http://127.0.0.1:8000/goodsdetails/后面
你可以使用表单提交的方式将输入的内容作为参数传递到http://127.0.0.1:8000/goodsdetails/后面,例如:
```
<form action="http://127.0.0.1:8000/goodsdetails/" method="GET">
<input type="text" name="q" value="请输入想找的宝贝">
<button type="submit">搜索</button>
</form>
```
在这个表单中,我们使用`method="GET"`将表单提交的方式设为GET请求,同时在输入框里指定了`name="q"`,表示输入的内容将以参数`q`的形式传递到URL中,例如:
http://127.0.0.1:8000/goodsdetails/?q=输入的内容
这样,在`http://127.0.0.1:8000/goodsdetails/`页面中,你可以通过`request.GET.get('q')`获取到输入的内容。
你可以使用表单提交的方式将输入的内容作为参数传递到http://127.0.0.1:8000/goodsdetails/后面,例如: 复制 <form action="http://127.0.0.1:8000/goodsdetails/" method="GET"> <input type="text" name="q" value="请输入想找的宝贝"> <button type="submit">搜索</button> </form> 在这个表单中,我们使用method="GET"将表单提交的方式设为GET请求,同时在输入框里指定了name="q",表示输入的内容将以参数q的形式传递到URL中,例如: http://127.0.0.1:8000/goodsdetails/?q=输入的内容 这样,在http://127.0.0.1:8000/goodsdetails/页面中,你可以通过request.GET.get('q')获取到输入的内容。这里q=前面的?如何去掉
如果你想去掉URL中的问号"?",可以使用Django中的reverse()函数和urlencode()函数来生成带参数的URL。示例代码如下:
```python
from django.urls import reverse
from urllib.parse import urlencode
def my_view(request):
query = request.GET.get('q', '')
url = reverse('goodsdetails') + '?' + urlencode({'q': query})
# ...
```
这里的reverse('goodsdetails')会生成/goodsdetails/这个URL,然后使用urlencode()函数将参数序列化为查询字符串,最终生成形如/goodsdetails/?q=xxx的URL。
相关推荐
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)