变量未插入url字符串

时间:2013-07-03 07:58:03

标签: javascript html

我面临的问题是从onsubmit函数中提取的变量没有正确地重新插入到url中。它给我留下了核心url字符串减去变量所在的位置以及变量

之后的所有内容
<html>
<BODY bgcolor="black"> 
<FONT size="2"><FONT color="red"><B>RET 5 MAN</B></FONT>
<TABLE>
<TBODY><TR><TD>
<FORM method="post" target="_parent" style="margin: 0;" action="http://impulse-ow.com/bar.html">
<INPUT name="sublogin" type="submit" style="width:150px" formtarget="_self"  value="HOME">
</FORM>
</TD>
</TD>  

<br>   


<TABLE>
<TBODY><TR><TD>
<FORM method="post" target="_new" style="margin: 0;" action="http://zimbob.outwar.com/world.php?suid=141535">
<INPUT name="sublogin" type="submit" style="width:75px"  value="FORM!">
</FORM>
</TD>
<TD> 
<FORM method="post" target="_new" style="margin: 0;" action="http://zimbob.outwar.com/joinraid.php?raidid=" + document.getElementsByID('linkfive').value; + "&" + uid=141535 + "&" + serverid=4 + "&" + "launchraid=yes">      
<INPUT name="launch" type="submit" style="width:75px"  value="LAUNCH!">
</FORM>
</TD>
</TR>
</TBODY></TABLE>
<br>


<form onsubmit="linkfive()" id="linkfive" method="post" >
<font color="red">Raid Link:</font><br> <input type="text" />
<input type="submit"  value="Submit" />
</form>




<TD><table>
<FORM method="post" target="_new" style="margin: 0;" action="http://impulse-ow.com/5mansin.html">
<INPUT name="sublogin" type="submit" style="width:75px"  value="SiN">
</FORM>
<FORM method="post" target="_new" style="margin: 0;" action="http://impulse-ow.com/5mantomes.html">
<INPUT name="sublogin" type="submit" style="width:75px"  value="Tomes">
</table>
 </form>   
</TD>

</TR>
<br>

<TABLE>
<TBODY><TR><TD>
<FORM method="post" target="_new" style="margin: 0;" action="http://zimbob.outwar.com/joinraid.php?raidid=" + document.getElementsByID('linkfive').value + "&" + suid36642>
<INPUT type="submit" style="width:150px" value="Account name" >
</FORM>
</TD>
</TR>

</TBODY></TABLE>

<script type="text/javascript">

function linkfive() {
     var linkfive = document.getElementById('linkfive').value
 }

</script>
</body>
</html>
像我之前说过的非常基本的编码。这可能有点草率或修复可能是我错过的一些愚蠢,但我已经在这5天好了,没有进展。

3 个答案:

答案 0 :(得分:1)

您将整个事物视为一个字符串。 试试这个:

<FORM method="post" target="_new" style="margin: 0;" action="http://genericurl.com/restofurl?url=" + document.getElementsByID('urlid').value + "&" + remainingurl>
    <INPUT name="sublogin" type="submit" style="width:150px"  value="Submit1">

这样你就不会按字面意思使用单词,而是使用其中的值。

您没有从输入字段中获取值。 在输入上放置一个ID,这样你就可以抓住它:

<form onsubmit="linkfive()"  method="post" >
<font color="red">Raid Link:</font><br> <input id="linkfive" type="text" />
<input type="submit"  value="Submit" />
</form>

这种方式document.getElementsByID('urlid').value将具有输入字段值。

答案 1 :(得分:1)

试试这个:

<FORM method="post" target="_new" style="margin: 0;" action="http://genericurl.com/restofurl?url=" + urlid.value + "&" + remainingurl>
<INPUT name="sublogin" type="submit" style="width:150px"  value="Submit1">

答案 2 :(得分:0)

尝试删除分号;来自urlid.value; 分开文字“&amp;”来自你的剩余变量

http://genericurl.com/restofurl?url=”+ urlid.value +“&amp;” + remainingurl

相关问题