替换两个输入中的两个 document.write 值
下面的 JavaScript 将此值 http://www.google.co.uk/webhp?hl=en
替换为 http://link-ads.blogspot.com/?url=http输入条目上的 %3A%2F%2Fwww.google.co.uk%2Fwebhp%3Fhl%3Den
。
<script type="text/javascript">
function showMe(e) {
paramencode = encodeURIComponent(e.value)
document.write('http://link-ads.blogspot.com/?url='+paramencode+'');
}
</script>
<input type="text" id="foo" placeholder="URL here" onchange="showMe(this)" />
它工作正常,但我现在需要包含一个从第二个输入继承到文档写入末尾的 &name=
+ 值。
document.write('http://link-ads.blogspot.com/?url='+paramencode+'&name='+andnameinput+'');
其中 '+andnameinput+'
将从第二个
EDITED 继承值 如果我将 http://www.google.co.uk/webhp?hl=en
插入第一个输入,则
<input type="text" id="foo" placeholder="URL here"/>
document.write 的输出应为 http://link-ads .blogspot.com/?url=http%3A%2F%2Fwww.google.co.uk%2Fwebhp%3Fhl%3Den
但它不完整,因为它应该有 &name= 前面的用户输入值我需要一点时间输入
<input type="text" id="foo2" placeholder="Name here"/>
并说明如果输入值 123456789,则从 document.write 返回的输出应为 http://link-ads.blogspot.com/?url=http%3A%2F%2Fwww.google.co.uk %2Fwebhp%3Fhl%3Den&name=123456789
the javascript below replaces this value http://www.google.co.uk/webhp?hl=en
with http://link-ads.blogspot.com/?url=http%3A%2F%2Fwww.google.co.uk%2Fwebhp%3Fhl%3Den
on input entry.
<script type="text/javascript">
function showMe(e) {
paramencode = encodeURIComponent(e.value)
document.write('http://link-ads.blogspot.com/?url='+paramencode+'');
}
</script>
<input type="text" id="foo" placeholder="URL here" onchange="showMe(this)" />
It works fine but I now need to inclue an &name=
+ value inherited from second input to the end of the document write ie.
document.write('http://link-ads.blogspot.com/?url='+paramencode+'&name='+andnameinput+'');
where '+andnameinput+'
will inherit the values from a second <input>
EDITED
if i insert http://www.google.co.uk/webhp?hl=en
into the first input
<input type="text" id="foo" placeholder="URL here"/>
the output from the document.write should be http://link-ads.blogspot.com/?url=http%3A%2F%2Fwww.google.co.uk%2Fwebhp%3Fhl%3Den
but it is incomplete as it should have &name= infront with a user input value for that i need a second input
<input type="text" id="foo2" placeholder="Name here"/>
and say if the value 123456789 was input the output returned from the document.write should be http://link-ads.blogspot.com/?url=http%3A%2F%2Fwww.google.co.uk%2Fwebhp%3Fhl%3Den&name=123456789
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解得很好你想要这样的东西:
If i understand well you want something like that: