I have this web page, say Home.html, that has links to other employee-related web sites. There is one, say www.SomeSite.com/HR.xyz, where it has a form to login. There are 3 fields: UserId, Password, and Company. The company is always the same, e.g. MyCo. How can I update the Home.html page so that when the user clicks on the link to , www.SomeSite.com/HR.xyz, it automatically populates the Company field with "MyCo"?
我有这个网页,比如Home.html,它有链接到其他员工相关的网站。有一个,比如www.SomeSite.com/HR.xyz,它有一个登录表格。共有3个字段:UserId,Password和Company。公司总是一样的,例如MYCO。如何更新Home.html页面,以便当用户点击指向www.SomeSite.com/HR.xyz的链接时,它会自动使用“MyCo”填充公司字段?
I looked at the DOM and found the following:
我查看了DOM,发现了以下内容:
<input autocomplete='off' class='loginInput' tabindex='3' type="text" name="company" id="company" value="" maxlength='50' size="25">
I tried the following by entering it in the URL and it did not work (no error, just didn't populated the "company" field: www.SomeSite.com/HR.xyz?company=MyCo.
我通过在URL中输入以下内容来尝试以下操作并且它不起作用(没有错误,只是没有填充“公司”字段:www.SomeSite.com/HR.xyz?company = MyCo。
Thanks for advice!
谢谢你的建议!
30
Change the value
attribute:
更改值属性:
<input autocomplete='off' class='loginInput' tabindex='3' type="text"
name="company" id="company" value="MyCo" maxlength='50' size="25">
5
You could try using a get request to populate the input box in the form. That's only if the url like you said is as such www.SomeSite.com/HR.xyz?company=MyCo. In PHP you would simply include:
您可以尝试使用get请求填充表单中的输入框。只有当你说的网址是这样的时候才会这样www.SomeSite.com/HR.xyz?company=MyCo。在PHP中,您只需包含:
<input autocomplete='off' class='loginInput' tabindex='3' type="text" name="company" id="company" value="<?php echo $_GET["company"]; ?>" maxlength='50' size="25">
” maxlength ='50'size =“25”>
As you can see that within the value attribute is a echo statement that echoes the get request in the URI where HR.xyz?company=MyCo contains the company get request. If you are using just pure html with no scripting language like php the only other method is by having this code:
正如您所看到的,value属性中的一个echo语句回显了URI中的get请求,其中HR.xyz?company = MyCo包含公司获取请求。如果你只使用没有像php这样的脚本语言的纯html,那么唯一的另一种方法就是使用这个代码:
<input autocomplete='off' class='loginInput' tabindex='3' type="text" name="company" id="company" value="myCo" maxlength='50' size="25">
2
If your users universally use Internet Explorer, you could do something a bit hackish with VBScript, e.g.
如果您的用户普遍使用Internet Explorer,您可以使用VBScript执行某些操作,例如:
Set IE = CreateObject("InternetExplorer.Application")
设置IE = CreateObject(“InternetExplorer.Application”)
IE.Navigate "http://www.SomeSite.com/HR.xyz"
IE.Navigate“http://www.SomeSite.com/HR.xyz”
IE.Visible = True
IE.Visible = True
IE.Document.All.Item("company").Value = "MyCo"
IE.Document.All.Item(“company”)。Value =“MyCo”
But that would be hard to distribute to your users because they would have to click through some security errors, and it requires IE.
但这很难分发给您的用户,因为他们必须点击一些安全错误,而且需要IE。
If they're Firefox users I would suggest looking into Mozilla Autofill.
如果他们是Firefox用户,我建议调查Mozilla Autofill。
1
You need some way of reading the value passed in the URL on the HR.xyz page. You need to either use Javascript or some server side logic (PHP, .NET, etc)
您需要一些方法来读取HR.xyz页面上URL中传递的值。你需要使用Javascript或一些服务器端逻辑(PHP,.NET等)
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2010/10/29/14076c531a1c1e5b14a7c6041c930692.html。