2011-05-17 35 views

回答

2

使用method="GET"放置在URL中的变量:

<form action="http://somewhere.com/" method="GET"> 
    Number: <input type="text" name="url" value="" /><br /> 

    <input type="submit" name="submit" value="Goto URL" /> 
</form> 

发布这种形式会去http://somewhere.com/?url=USER_INPUT_URL

+0

由你缺少提交按钮或'document.name.submit()' – Sourav 2011-05-17 03:43:08

+0

@Sourav方式,即用完整的形式更新。 – mellamokb 2011-05-17 03:44:36

+0

工作。谢谢。 – coolbluelogo 2011-05-19 22:05:46

-1
<form> 
Number: <input type="text" name="url1" id="url1" value=""><br> 
<input type="submit" name="submit" value="Goto URL" onclick="redirect()"> 
</form> 

<script> 
function redirect() 
{ 
    window.location='http://somewhere.com?url=' + document.getElementByID('url1').value; 
} 
</script> 
+0

这是谁的错? – Sourav 2011-05-17 03:42:01

-1

不同从1日。没有形式需要,为文本字段添加一个名为'id'的属性,然后定义一个javascript函数来检索textfield的值,然后执行跳转,希望有用。

<form action="?????" method="?????"> 

Number: <input id="url1" type="text" name="url1" value=""><br> 

<input type="button" name="submit" value="gotoURL()"> 
</form> 

<script> 
function gotoURL(){ 
window.location='http://somewhere.com?url='+document.getElementById('url1').value; 
} 
</script> 
相关问题