Link to home
Start Free TrialLog in
Avatar of joe90kane
joe90kane

asked on

How to Auto Populate a text box with Page URL

Hi All,

I need to Auto Populate a text box with Page URL. Im not sure where to start.

I have the form but I need the script.

Thanks, Joe
ASKER CERTIFIED SOLUTION
Avatar of Göran Andersson
Göran Andersson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
if you are not using DOM-based, here's how to do it in forms.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Third Santor</title>
<script>
window.onload = function(){
  var url = window.location.href;
  document.form1.The_Id_Of_The_TextBox.value = url;
}
</script>
</head>
<body onload="document.getElementById('The_Id_Of_The_TextBox').value=window.location.href;">
<form name="form1" method="post" action="" onsubmit="return ">
<input type="text" name="The_Id_Of_The_TextBox" value="" />	
</form>
</body>
</html>

Open in new window

Avatar of joe90kane
joe90kane

ASKER

Worked Perfect - Thanks GreenGhost
GreenGhost:
I read your answer with interest. I have a similar situation where i have a form with a text box. I am attempting to find a solution to populate this textbox from a link to a URL that contains parcel id. For example: http://www.anyapp.net/Default.aspx?ParcelID=HR12345 .

I would like to have my form capture this URL into a specific textbox.

ANY help would be greatly appreciated.