Sending ASP ADO Recordset Value to Javascript Function

C

Chris

I am new to these forums and hope I am in the right place!

I am working on an ASP (3.0) page that displays hotel data from a
recordset in a table. In the last column of each row, I want to include
a button that will send the address information of this hotel to
mapquest to display the map. I have tried several methods for sending
this info, but nothing seems to work.

Here is my code for the javascript function I am calling:

<SCRIPT LANGUAGE="JavaScript">
function goToMapquest(oRSHotels("hotelStreet"), oRSHotels("hotelCity"),
oRSHotels("hotelState"), oRSHotels("hotelZipCode")) {

window.location =
"http://www.mapquest.com/maps/map.ad...ntry=US&addtohistory=&searchtab=home&address=<%
=Replace(oRSHotels("hotelStreet"), CHR(32), "+") %>&city=<%
=oRSHotels("hotelCity") %>&state=<% =oRSHotels("hotelState")
%>&zipcode=<% =oRSHotels("hotelZipCode") %>";
}
</script>

This is the table cell:

<td class="Log"><input type="button" value="Map"
onclick="goToMapquest(oRSHotels("hotelStreet"), oRSHotels("hotelCity"),
oRSHotels("hotelState"), oRSHotels("hotelZipCode"))" id=button1
name=button1></td>


This clearly is not working! I am not too familiar with javascripting
and was wondering if there might be a better way to send these
recordset values?
 
M

Martin Walke

Chris said:
I am new to these forums and hope I am in the right place!

I am working on an ASP (3.0) page that displays hotel data from a
recordset in a table. In the last column of each row, I want to include
a button that will send the address information of this hotel to
mapquest to display the map. I have tried several methods for sending
this info, but nothing seems to work.

Here is my code for the javascript function I am calling:

<SCRIPT LANGUAGE="JavaScript">
function goToMapquest(oRSHotels("hotelStreet"), oRSHotels("hotelCity"),
oRSHotels("hotelState"), oRSHotels("hotelZipCode")) {

window.location =
"http://www.mapquest.com/maps/map.ad...ntry=US&addtohistory=&searchtab=home&address=<%
=Replace(oRSHotels("hotelStreet"), CHR(32), "+") %>&city=<%
=oRSHotels("hotelCity") %>&state=<% =oRSHotels("hotelState")
%>&zipcode=<% =oRSHotels("hotelZipCode") %>";
}
</script>

This is the table cell:

<td class="Log"><input type="button" value="Map"
onclick="goToMapquest(oRSHotels("hotelStreet"), oRSHotels("hotelCity"),
oRSHotels("hotelState"), oRSHotels("hotelZipCode"))" id=button1
name=button1></td>


This clearly is not working! I am not too familiar with javascripting
and was wondering if there might be a better way to send these
recordset values?


Hi Chris,

You're a bit mixed up but almost there! You don't need to get the ADO data
again in your javascript function.

<script type='text/javascript'>
function goToMapquest(street, city, state, zip) {
window.location =
'http://www.mapquest.com/maps/map.ad...ntry=US&addtohistory=&searchtab=home&address='
+ street + '&city=' + city + '&state=' + state + '&zipcode=' + zip;
}
</script>

You may need to enclose each variable with the encode() function. e.g..... +
encode(street) + ...

And then in each cell in your table

<td class="Log"><input type="button" value="Map"
onclick="goToMapquest(<%=oRSHotels("hotelStreet")%>,<%=oRSHotels("hotelCity")%>,<%=oRSHotels("hotelState")%>,<%oRSHotels("hotelZipCode")%>)"
id=button1 name=button1></td>

HTH
Martin
 
M

McKirahan

Chris said:
I am new to these forums and hope I am in the right place!

I am working on an ASP (3.0) page that displays hotel data from a
recordset in a table. In the last column of each row, I want to include
a button that will send the address information of this hotel to
mapquest to display the map. I have tried several methods for sending
this info, but nothing seems to work.

[snip]

http://www.aspfaq.com/5003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top