Click to See Complete Forum and Search --> : Receiving part of a url from a form and opening it in a new window?


DOCH
03-12-2006, 03:21 PM
i am trying to have a page on my site which where i send the postcode, it goes in to part of a url line which opens a new page and it will show me the map of that area,
i need the below code to work so that it receives a postcode from a form in another asp file, i have tried modifying it to make it work but i aint got a clue.

the code:-


<script language="javascript">
function go() {
var loc = "http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=" + <%Request.Form("Postcode")%> + ""
location.href = loc;
}

the <%Request.Form("Postcode")%> is the bit where the problem is, the from which is in another asp file submits to this file and i was hoping that it would place the postcode in that part of the url line,
after i type in the postcode, and submit it to the asp page containing the code above all i get is a IE window displaying the line:-
function go() { var loc = "http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=" + + "" location.href = loc; }
another thing is how do i get that code to open in a new window and go to the url

very grateful to any one who can help, thankyou

chrismartz
03-12-2006, 07:47 PM
The code of <%Request.Form("Postcode")%> will not show anything on the page. To get the information stored in the form id of postcode, you can use <%= Request.Form("Postcode") %>

DOCH
03-13-2006, 12:40 PM
tried that mate it dosnt work, any other ideas? thanks for replying.

JayM
03-13-2006, 01:37 PM
edited...

DOCH
03-13-2006, 02:58 PM
hi, thanks for replying. i have tried the code you recommended and its opening up in a new window but with the old windows a url and http%3A%2F%2Fwww%2Estreetmap%2Eco%2Euk%2Fstreetmap%2Edll%3Fpostcode2map%3Fcode%3Dtarget= straight after it.

any ideas on whats going wrong?
thankyou

JayM
03-13-2006, 05:20 PM
Oh, it's linking to another site. Disregard my previous entry. What you have initially done is correct and should work.


<script language="javascript">
function go() {
var loc = "http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=" + <%Request.Form("Postcode")%> + ""
location.href = loc;
}

Did you make sure you have a </script> tag above? Sometimes simple mistakes like this could screw things up.

You could always do something like this:


PostCode = Request.Form("Postcode")
strURL = "http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=" & PostCode



<a href="<% = strURL %>" target="_blank">Link 1</a>

DOCH
03-13-2006, 06:21 PM
at the moment the code looks like this:-
<html>

<head>
<title>New Page 1</title>
</head>
<body>

<form name="form1" method="POST" action="abc2.asp">
<input type="text" name="postcode">
<input type="submit" value=" Go ">
</form>
</body>
</html>
code above is from the page called abc.asp its basically the form
below is the code from page called abc2.asp which the form submits to

<%@ Language=VBScript %>
<% Option Explicit %>
<!--#include file="adovbs.inc"-->

<script language="javascript">
function go() {
var loc = "http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=" + <%=Request.Form("Postcode")%> + ""
location.href = loc;
}

</script>

what happens is when i type in the postcode in the form in abc.asp and press submit it goes to abc2.asp but the page is blank, i know that the postcode is submitting to the 2nd page because if i put the line Response.Write(Request.Form("Postcode")) in the page abc2.asp it shows me the postcode which i entered in to the form.

hope you can help me on this, thanks again for replying its very much appreciated

JayM
03-13-2006, 06:36 PM
It's going to be blank if that's all there is on abc2.asp. You have a javascript function, but you don't call it.

Add this to abc2.asp:

<%
PostCode = Request.Form("Postcode")
strURL = "http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=" & PostCode

Response.Redirect(strURL)
%>

DOCH
03-14-2006, 03:49 AM
That worked!! Thankyou so much for your help.

JayM
03-14-2006, 04:24 PM
You're welcome :)