Hi,
I have been sent some postcode software to integrate into a crm system that i use. I have linked it from the html page to a popup asp page (see second lot of code below). I need to pull the data back into the html using javascript, or ASP to insert it in the database, what ever is easiest.
I can set a connection to the database and execute an insert statement but i can't see how to set varibles to the following. I.E. addressline3 = taskObj.AddressLine3 doesn't work.... here is a sample from the code below. Javascript might be a better way??
This is the query that is sent to the popup page when the image at the end of the postcode field is clicked. It takes the postcode and the address field over for the postcode search code to locate the correct address. if just the postcode is sent then it displays multiple address to select from, if the address line 1 and postcode are populated, the code finds the exact address if it exists.
I need to be able to take the address once located from the ASP page and populate the form fields on the html page.
example HTML code:
example ASP code:
This is the code that sits in the popup page
Hope someone can make sense of this
Thanks
I have been sent some postcode software to integrate into a crm system that i use. I have linked it from the html page to a popup asp page (see second lot of code below). I need to pull the data back into the html using javascript, or ASP to insert it in the database, what ever is easiest.
I can set a connection to the database and execute an insert statement but i can't see how to set varibles to the following. I.E. addressline3 = taskObj.AddressLine3 doesn't work.... here is a sample from the code below. Javascript might be a better way??
Code:
taskObj.AddressLine3 = Request.Form("addressElements")
taskObj.AddressLine4 = Request.Form("addressElements")
taskObj.County = Request.Form("addressElements")
taskObj.Postcode = Request.Form("addressElements")
This is the query that is sent to the popup page when the image at the end of the postcode field is clicked. It takes the postcode and the address field over for the postcode search code to locate the correct address. if just the postcode is sent then it displays multiple address to select from, if the address line 1 and postcode are populated, the code finds the exact address if it exists.
I need to be able to take the address once located from the ASP page and populate the form fields on the html page.
example HTML code:
Code:
<tr>
<td>County</td>
<td><input type=text name=county></td>
</tr>
<tr><td class=ContactBoldText>Postcode</td>
<td class=ContactBoldText><input type=text class=ContactZipTextField name=postcode><a href="javascript:loadwindow('postcode_satori.asp?address=<#field field=address>&postcode=<#field field=postcode>&contactid=<#field field=1>&mapvalue=1',820,300)"><img src="images/zcimage.jpg" border=0 align=absmiddle></a>
example ASP code:
This is the code that sits in the popup page
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>UK Addressing ASP Sample</title>
<style type="text/css">
.addressResults{padding: 0px 0px 0px 170px;
}
#container{
width:790px;
margin-top: 10px;
margin-left: 15%;
margin-right: 15%;
padding: 10px;
font-family: "Segoe UI","verdana";
font-size:10pt;
border: 1px solid #4465A2;
background-color: white;
}
#select1{
font-family:verdana;font-size:7pt;
width:590px;
}
h3{color: #4465A2;}
</style>
<script language="JavaScript">
function validate()
{
var addressInput = document.getElementById("addressElements").value;
if(addressInput.length > 0)
{
return true;
} else {
alert("Please enter an Address Element:");
return false;
}
}
function displayAddress()
{
var strAddress = document.form1.select1.options[document.form1.select1.selectedIndex].value;
document.getElementById("addressResult").innerHTML = "<span style=\"color:#4465A2\" ><strong>Certified address</strong></span>:<br>";
document.getElementById("addressResult").innerHTML += strAddress.replace(/\n/g,"<br>");
alert(document.getElementById("addressResult").innerHTML)
}
</script>
</head>
<body>
<div id="container">
<h3>UK Address</h3>
<form action="" method="post" name="form1" id="form1" onSubmit="return validate()">
<label for="addressElements">Enter Address Elements:</label>
<input type="hidden" name="postBack" id="postBack" value="true">
<input type="text" name="addressElements" id="addressElements" size="50" maxlength="75" value="<%If Request.Form("addressElements") <> "" Then%><% =(Request.Form("addressElements"))%><% Else%><% =(Request.QueryString("address"))%> <%=(Request.QueryString("postcode"))%><%End If%>">
<input type="submit" name="btnSubmit" id="btnSubmit" value="Search">
<%
if(Request("postBack") = "true") Then
on error resume next
' --------------------------------------------------------------------------------
' Step1. Create a MailRoom ToolKit Architect PostCodeTask COM object.
' Step 2. Prepare the object for use
' Step 3. Add your address Elements
' Step 4. Check your address
' Step 5. Save Results
' Step 6. Clean up object
'Step1. Create the MailRoom ToolKit Architect PostcodeTask object
Set taskObj = server.CreateObject("MRTKUK.UKPostCodeTask.1")
' Step 2. Prepare the object for use
taskObj.SilentMode = true
taskObj.MailRoomServer = "" ' Add server here for Client/Server mode
taskObj.PrepareTask
taskObj.ClearAddress
' Step 3. Add your address Elements
'taskObj.Postcode = Request.Form("addressElements")
'taskObj.PostTown = Request.Form("addressElements")
taskObj.AddressLine1 = Request.Form("addressElements")
taskObj.AddressLine2 = Request.Form("addressElements")
taskObj.AddressLine3 = Request.Form("addressElements")
taskObj.AddressLine4 = Request.Form("addressElements")
taskObj.PostTown = Request.Form("addressElements")
taskObj.County = Request.Form("addressElements")
taskObj.Postcode = Request.Form("addressElements")
'Step 4. Check your address - this function will try to certify the address containted in the UKPostCodeTask Object
taskObj.CheckAddress
'Step 5. Save Results
If(taskObj.ErrorCode >= 100 And taskObj.ErrorCode < 500 ) Then
'Error Codes are 100 to 499 - Status Codes are 0-100 and 500+
' Uncomment to view error code '
'Response.Write("ErrorCode: " & taskObj.ErrorCode & " | " & taskObj.ErrorCodeString(true))
'No certifed address returned by checkAddress()
' call searchAddress() to return a list of possible matches
taskObj.clearAddress()
taskObj.PrepareTask()
taskObj.SearchCount = 20
taskObj.PostCode = Request.Form("addressElements")
taskObj.SearchAddress()
If Err.number = 0 Then
Response.Write "<p><label for=""select1"" style=""vertical-align:top;padding-right:50px;"">Address Matches:</label>"
Response.Write "<select name=""select1"" id=""select1"" size="""&taskObj.SearchCount&""" onchange=""displayAddress()"">"
For i=1 to taskObj.SearchCount
Response.Write("<option value="""&taskObj.AddressBlock &""">"&taskObj.AddressBlock&"</option>")
If i < taskObj.SearchCount Then
taskObj.NextAddress()
End If
Next
Response.Write("</select></p>")
Else
Response.Write("<p>No results found.</p>")
End If
Else
'Display matched address returned by checkAddress()
Response.Write("<p class=""addressResults""><h4><Certified address</h4>")
'Response.Write(replace(taskObj.PostTown,VBCR, "<br>")&"</p>")
response.write(taskObj.addressblock)
End If
'Step 6. Clean up object
taskObj.EndTask()
End If
'--------------------------------------------------------------------------------------------------------------------------------------
%>
</form>
<p>
<div class="addressResults" id="addressResult"> </div>
</p>
<script language=""JavaScript"">
if(document.form1.select1)
{
document.form1.select1.focus();
if(document.form1.select1.selectedIndex == 0)
{
document.form1.select1.selectedIndex=0;
displayAddress()
}
}
</script>
</div>
</body>
</html>
Hope someone can make sense of this
Thanks