0

如果您在下面看到,我的代码允许用户输入一个带有 IP 地址的字段,并允许他们远程进入。现在我已经更改了它,所以在 IP 之后它将信息添加到链接之后,但我需要它包含 http: / 之前自动但我必须将它包含在输入框中,这是我不想要的:

<p>Please fill in the box with your IP address: 
<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://"
    onclick="this.href=(document.getElementById('prog_site').value +
                       '/web/entry/en/websys/atRemote/atRemoteSetupGet.cgi')"
    target="_blank">Let's go!</a></p>

我已经更改了以下内容,我更接近了吗?

<p>Please fill in the box with your IP address: 
<input type="text" name="prog_site" id="prog_site" value="http://" />
<a href="http://"
    onclick=".value + 'http:// ',this.href=(document.getElementById('prog_site').value +
                       '/web/entry/en/websys/atRemote/atRemoteSetupGet.cgi')"
    target="_blank">Let's go!</a></p>
4

2 回答 2

1

好的,所以我想我已经通过在这里和那里修复一些错别字来让它工作:

<p>Please fill in the box with your IP address: 
    <input type="text" name="prog_site" id="prog_site" value="" />
    <a href="#"
       onclick="this.href = ('http://' + document.getElementById('prog_site').value + '/web/entry/en/websys/atRemote/atRemoteSetupGet.cgi')"
       target="_blank">Let's go!</a>
</p>

用于测试的小提琴:http: //jsfiddle.net/mC4vT/1/

于 2013-07-19T11:07:59.593 回答
0

你可以用更简单的方式来做。

创建一个变量$link='http://';,然后将从文本字段中选择的 ip 与它连接起来,然后将其$link用作最终结果。

于 2013-07-19T11:19:46.580 回答