开发者

Autofill Text Field Value with Current Page URL

开发者 https://www.devze.com 2023-04-02 10:18 出处:网络
All I am looking to do is autofill a hidden text field with the current page URL, so that when the开发者_开发问答 user submits the form, I know the page they sent the form from. This will save me a to

All I am looking to do is autofill a hidden text field with the current page URL, so that when the开发者_开发问答 user submits the form, I know the page they sent the form from. This will save me a ton of headaches dealing with inquiries.

In other words, when the page loads, I'd need the text field value to be value="http://www.example.com/"

Ideally, looking to accomplish this with just Javascript/HTML.

Any help would be much appreciated. Thanks!


Assuming you can give your hidden field an ID, put the following in your onload or document-ready processing:

document.getElementById("yourHiddenFieldId").value = window.location.href;
0

精彩评论

暂无评论...
验证码 换一张
取 消