首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

请问!form中action=url,此url为变量怎么处理?

2012-02-13 
请教!form中actionurl,此url为变量怎么办??formname f method post action target result

请教!form中action=url,此url为变量怎么办??
<form   name= "f "   method= "post "   action= " "   target= "result ">
<input   name= "address "   type= "text "   value= "在此输入网址 "   />
<input   name= "gourl "   type= "submit "   value= "go "   />
</form>

想给action传递在text框中输入的网址值该怎么办???

[解决办法]
明白你的意思,类似导航功能
<form name= "f " method= "post " action= " " onsubmit= "return go(); " target= "result ">
<input name= "address " type= "text " value= "在此输入网址 " />
<input name= "gourl " type= "submit " value= "go " />
</form>
<script>
function go(){
location.href=f.address.value;
}
</script>

但没必要用表单吧,太麻烦了,直接用链接加JS
[解决办法]
直接在
<form id= "form1 " name= "form1 " method= "post " action= " ">
<input type= "button " name= "Submit " value= "返回 " onclick= "javascript:location.href= '链接URL ' " />
</form>
[解决办法]
按照你的说法,应该是在两个 iframe 之间的吧?
第一个 iframe ,放输入表单
<iframe src= "..... " name= "iframe1 " id= "iframe1 " />
第二个 iframe ,打开第一个 iframe 中输入的网址
<iframe src= "about:blank " name= "iframe2 " id= 'iframe2 " />

第一个 iframe 中的代码大致如下:
<form id= "form1 " name= "form1 " action= " " onsubmit= "submitForm() " target= "iframe1 ">
<input type= "text " name= "url " id= "url " />
<input type= "submit " />
</form>

<script type= "text/javascript ">
function submitForm() {
var url = document.getElementById( 'url ').value;
if (url== ' ') return false;
var iframe2 = document.getElementById( 'iframe2 ');
iframe2.setAttribute( 'src ', url);
return false;

}
</script>

写得匆忙,可能有错,楼主调试一下 ^_^
[解决办法]
<form name= "f " method= "post " action= " " target= "result ">
<input name= "address " type= "text " value= "在此输入网址 " />
<input onclick= "goto() " name= "gourl " type= "button " value= "go " />
</form>
<SCRIPT LANGUAGE= "JavaScript ">
<!--
function goto()
{
f.action= "http:// "+f.address.value;
f.submit();
}
//-->
</SCRIPT>

热点排行