html怎么处理文本框输入的内容

求解


我需要一个html页面,这个页面里面有一个输入框,一个提交

我在文本框中输入,https://segmentfault.com/  ,然后点提交的时候 打开的是这个页面http//localhost/y.php?_u=https://segmentfault.com/   

这个要怎么实现,小白求助


眼眸繁星
浏览 815回答 2
2回答

富国沪深

试一下这个<input id="name" type="text"><button onclick="Submit();">提交</button><script>&nbsp; &nbsp; let url = 'http://localhost/y.php?_u=';&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; function Submit () {&nbsp; &nbsp; &nbsp; &nbsp; let name = document.getElementById('name'),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nameValue = name.value&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Url = '';&nbsp; &nbsp; &nbsp; &nbsp; Url = url + nameValue;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; console.log(Url);&nbsp; &nbsp; &nbsp; &nbsp; window.location = Url;&nbsp; &nbsp; }</script>

小怪兽爱吃肉

form
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript