【发布时间】:2014-05-17 08:56:15
【问题描述】:
我有两个输入字段
字段 1 和字段 2
我想在点击提交按钮时生成一个外部链接
例如链接如下,
www.mystie.com/field1 + sometext + field2
我需要这个公式与谷歌地图方向一起使用
【问题讨论】:
标签: java javascript html textfield
我有两个输入字段
字段 1 和字段 2
我想在点击提交按钮时生成一个外部链接
例如链接如下,
www.mystie.com/field1 + sometext + field2
我需要这个公式与谷歌地图方向一起使用
【问题讨论】:
标签: java javascript html textfield
用户 request.getParameter( "field1" ) 在您的操作 servlet 中
String link = request.getParameter( "field1" ) +"sometext" + request.getParameter( "field2" );
你的 html 在哪里
<form action="myServlet" method="post">
<input name="field1"/>
<input name="field2"/>
</form>
【讨论】:
String link = String.format("www.mysite.com/%s/sometext/%s",field1.getText(),field2.getText());
【讨论】:
您可以使用 Javascript 来执行此操作。
试试这个
function submitclick(){
var text1= document.getElementByID("feild1").value;
var text2= document.getElementByID("feild2").value;
document.getElementByID("submitbuttonATag").href=text1+sometext+text2;
// Finally when the link is modified generate click
document.getElementByID("yourA_tag").click();
}
【讨论】:
使用 jquery
("#submitButton").click(function(){
var url="www.mysite.com/";
url= url + $("#feild1").val();
url = url + "sometext";
url = url + $("#feild2").val();
//Then use your url
});
【讨论】: