Saturday, January 7, 2012

Please help with link syntax to find a zip code definition on usps.com?

hi,


i need to include a link in a html page to a zip code so that when the user clicks the zip code it opens a browser and sends him to usps.com and looks up the zip code to give him the city. I have the link, but i cannot figure out the syntax to put the zip code in the link to do the lookup. Can someone please help? Here is the link:





http://zip4.usps.com/zip4/citytown_zip.jsp





thankx|||There are a few different options I could give you, but they might not be what you're looking for.


The first one is that if you just want to look up zip codes, you could create a page with google search box on it. The link is here: http://www.google.com/cse/





With the google search box, it just functions like you would be googling something on google, meaning you just enter a zip code, and that would open a new tab with the google search query giving them the location of the zip code.





The second way is almost similar but only that you would create that search on google on your own using a scripting langauge, or if not google, something like www.city-data.com/zips/90064.html


Where the zip code might be $zc = whatever users enter and the link would be www.city-data.com/zips/$zc.html





So every time the user hits the link, the $zc changes to whatever zip code the user had typed.





You might require a dynamic scripting language like PHP.





Here's quickly what you could try if you know a dynamic scripting language.





With PHP,





$zc = $_POST(zipcode);|||View the source for the page where you found that link to see what you are really clicking on that takes you to it. That's what I did once to create a perl script that would text me whenever a server had problems. My wireless carrier had a web form to send text. I used the source for that to figure the rest of it out.|||You'd have to append the following to your URI (link) above to populate the text box on the "citytown" page:





?zip5=94555


Note that "zip5" is the name of the text box which gets populated. (Yahoo annoyingly trims long strings, so here's what the full URI would look like, except you'd have to remove the spaces: http://zip4.usps.com/zip4/ citytown_zip.jsp ?zip5=94555 .)





But the user would still have to click the submit button, so if you want it to automatically show them the relevant city, you'd have to post a form to the same page being posted to from your link above. Viewing source shows this:





%26lt;form onsubmit="return validate(form1)" method="post" action="zcl_3_results.jsp" name="form1"%26gt;


Note that you'll have to use the fully qualified URI for the "action" value, i.e., "http://zip4.usps.com/zip4/ zcl_3_results.jsp" (remove space).





You'll have to also copy the %26lt;input%26gt; names they use in order to have the appropriate values be posted on form submit. Here are the %26lt;input%26gt; tags you'd need, again retrieved from viewing source:





%26lt;input type="text" name="zip5" maxlength="5" style="width: 75px;" id="zip5" value="" tabindex="1"/%26gt;


%26lt;input width="70" type="image" height="17" title="Submit" src="images/button_submit_akqa.gif" value="Find ZIP Code" tabindex="8" name="submit"/%26gt;





I removed the "onkeypress" attribute -- you'll have to do any event handling as you see fit.

No comments:

Post a Comment