简体   繁体   English

html中的用户输入url修饰符

[英]User input url modifier in html

I am creating a site for a city and am going to add a phone number lookup box on it. 我正在为一个城市创建一个站点,并将在其上添加电话号码查找框。 I would like it to be pure html and simple. 我希望它是纯HTML和简单的。 I need somekind of user input boxes so in one box they could type the first name, then next box the last name, then a city box, then a state box. 我需要某种用户输入框,因此在一个框中可以输入名字,然后在下一个框输入姓氏,然后输入城市框,然后输入州框。 So when they push submit it fits it in this url: http://www.yellowpages.com/whitepages?first=FIRSTNAMEHERE&last=LASTNAMEHERE&zip=ZIPCODEHERE&state=STATEHERE 因此,当他们推送时,它适合此URL: http : //www.yellowpages.com/whitepages? first = FIRSTNAMEHERE&last = LASTNAMEHERE&zip = ZIPCODEHERE&state= STATEHERE

I have tried jQuery and it sort of worked but want to move on to pure html. 我已经尝试过jQuery,并且它确实可行,但希望继续使用纯HTML。

The code I have tried is: 我尝试过的代码是:

 <input id="input" name="url" onfocus="this.value='';" style="border: 1px solid 
#A4A4A4; font-size: 0.9em; padding: 5px; width: 350px;" type="text" value="Type url here..">
<input onclick="window.open('http://www.yellowpages.com/whitepages?first=&last=&zip=&state=' + 

window.document.getElementById('input').value.replace(/^https?:\/\//,''))" style="font-family: Arial, sans-serif; font-size: 0.9em; margin: 2px 0; padding: 

4px; width: 100px;" type="button" value="Surf">

I know I am making the mistake somewhere in the "onclick" value. 我知道我在“ onclick”值中的某个地方犯了错误。

Sounds like you need just a simple GET request for your form. 听起来您只需要对表单进行简单的GET请求即可。 A GET request means it passes data to a page via URL parameters. GET请求表示它通过URL参数将数据传递到页面。 This code takes every submitted input name and puts the data it contains after your yellowpages URL. 此代码采用每个提交的输入名称,并将其中包含的数据放在黄页URL之后。

<form method="get" action="http://www.yellowpages.com/whitepages">
    <input name="first" type="text">
    <input name="last" type="text">
    <input name="zip" type="text">
    <input name="state" type="text">
    <input type="submit" value="Submit">
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM