使用jquery、javascript或PHP生成查询字符串
我有一个用户可以填写的表单,我需要用户能够使用查询字符串生成带有结果的pdf 范例使用jquery、javascript或PHP生成查询字符串,php,javascript,jquery,autofill,Php,Javascript,Jquery,Autofill,我有一个用户可以填写的表单,我需要用户能够使用查询字符串生成带有结果的pdf 范例 1234 2134 谢谢 HTML: <a href="#" id="pdf_a">click here</a> 例如: 这将取opt1和opt2的值,并将其作为opt1=x&opt2=y放入url中 <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/li
1234
2134
谢谢 HTML:
<a href="#" id="pdf_a">click here</a>
例如:
这将取opt1和opt2的值,并将其作为opt1=x&opt2=y放入url中
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#my_link").click(function(){
opt1 = $("#opt1").val(); // Stores the value of id-opt1 in the variable opt1
opt2 = $("#opt2").val(); // Stores the value of id-opt2 in the variable opt2
url = "url.pdf?opt1=" + opt1 + "&opt2=" + opt2; // Takes the above variables and creates the query to send to your file.
window.location = url;
});
});
</script>
</head>
<body>
<form id="form">
<select name="test" id="test">
<option id="op1" value="1">1234</option>
<option id="op2" value="2">2134</option>
</select>
</form>
<a id="my_link"> click here</a>
</body>
$(文档).ready(函数(){
$(“#我的链接”)。单击(函数(){
opt1=$(“#opt1”).val();//将id-opt1的值存储在变量opt1中
opt2=$(“#opt2”).val();//将id-opt2的值存储在变量opt2中
url=“url.pdf?opt1=“+opt1+”&opt2=“+opt2;//获取上述变量并创建要发送到文件的查询。
window.location=url;
});
});
1234
2134
点击这里
FillStringHere应该如何生成?它应该生成用户选择的值为什么不直接使用表单帖子?在正文
标记外有一个锚。请给我一个如何使用它的示例,好吗?我对JavaScription不太在行这太完美了!我一开始没意识到,但现在我明白了!谢谢你,伙计!我有一百万次使用这个..你在主体
标签外有一个锚。谢谢!如果我还想在查询字符串上显示某些元素的文本值和其他元素的实际值,我该怎么做?编辑并在答案中添加注释,以便于理解。添加变量并获取所需的值,修改url变量以反映要发布到pdf文件的其他数据。
$(document).ready(function(){
$('#pdf_a').click(function(){
$(this).attr('href', 'url.pdf?'+$('#form').serialize());
});
});
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#my_link").click(function(){
opt1 = $("#opt1").val(); // Stores the value of id-opt1 in the variable opt1
opt2 = $("#opt2").val(); // Stores the value of id-opt2 in the variable opt2
url = "url.pdf?opt1=" + opt1 + "&opt2=" + opt2; // Takes the above variables and creates the query to send to your file.
window.location = url;
});
});
</script>
</head>
<body>
<form id="form">
<select name="test" id="test">
<option id="op1" value="1">1234</option>
<option id="op2" value="2">2134</option>
</select>
</form>
<a id="my_link"> click here</a>
</body>