php - 使用文本框中的参数调用 php
问题描述
我想制作一个有文本框的网站,如果用户输入“hello”并单击提交,我想显示 example.com/test.php?link=hello 我该怎么做?php 已经写好了我只需要用 html 或 php 做一些东西就可以显示 example.com/test.php?link=whatUserEnters
谢谢!
解决方案
<!DOCTYPE html>
<html>
<body>
<!--just create a text box, give an id to it.-->
<input type="text" id="text_to_display" />
<input type="button" value="Submit" onClick="concat();" />
<!--Create a label or div assign a separate id to it too.-->
<p id="concatenated_text"></p>
<script>
//Create a function in javascript.
function concat() {
//Get the value in function using that id.
var text = document.getElementById("text_to_display").value;
//Concatenate the value with the string and put it in div using id.
var final_text = "example.com/test.php?link="+text;
// you can use location.href to use it for link purpose
location.href = final_text;
}
</script>
</body>
</html>
推荐阅读
- php - 获取有很多关系数据 Laravel 并使用 avg 函数
- r - R - 使散点图看起来像一个点图,计数高于和低于零
- actionscript-3 - 将事件侦听器添加到多维数组
- asp.net-core - 填充 AspNetUserLogins 和 AspNetUserTokens
- r - 如何将多个excel文件中的多张工作表导入一个列表-readxl R
- python - 熊猫将框架的列与列名中的部分匹配合并
- html - form action="" HTML 处理表单的动作代码是什么?
- xml - XML - XSLT - 使用两个 XML 文件 - 对 XML 文件的补充咨询另一个 XML 文件
- visual-studio - eShopOnContainer - Docker:Visual Studio 在尝试加载 mvc 页面时出现异常
- c++ - 如果我在 decltype 中使用 std::string 模板参数替换失败