A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Range of ZIP CODES

  1. #1
    Senior Member
    Join Date
    Jan 2003
    Location
    @Home
    Posts
    104

    Range of ZIP CODES

    Hi there,
    I have a rang of zip codes where my company can delivery shipments within 24 hours, only in places located in that range of zip codes.
    So, based on that information, I´d like to add a search box in the flash movie that I´m working on, this way WE can type the zip code in the search box and press SEARCH. If the user types a zip code that is within that range the actionscript would recognize it and show for example:
    "THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE"
    But if the user enters a zip code that is not withing the range codes then show:
    "THE ZIP CODE YOU ENTERED IS NOT WITHIN THE 24 HS ZONE"

    Example of my range of zip codes:
    01000-01099 (any zip code starting in 01000 and ending in 01099)
    01500-01599 (any zip code starting in 01500 and ending in 01599)
    and so on
    Please note that I have more than one range of zip codes.
    How do I set my IF actions to work as follow:
    if (zipcode >=0100 && zipcode<=01099){
    message = "THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE";
    }else if{
    and so on

    WILL IT WORK??? I HAVE ALREADY TRIED AND IT DIDN´T WORK HERE.
    One thing that I don´t understand. What is the difference between = and == ??
    In this case, should I use >==???
    ====================
    I love this forum!!!
    Pilot_22
    ====================

  2. #2
    I Mastered Dead Technology TallGuyLittleCar's Avatar
    Join Date
    Nov 2001
    Location
    looking for my lighter
    Posts
    669
    = is an assignment operate
    i.e. :

    zipcode = 5;

    will tell flash that the variable zipcode equals 5

    == is a test for equality.

    zipcode == 5;

    will tell flash to figure out if zipcode equals 5.

    in if statements you are almost always going to use ==


    if (zipcode >=0100 && zipcode<=01099){
    message = "THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE";
    }else if{
    and so on


    what I think might work is

    if ( (zipcode >= 0100) && (zipcode <=01099) ){
    message = "THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE";
    }esle if{
    ONLY RON PAUL AND ALUMINUM FOIL CAN SAVE YOU NOW!
    annoy your politician fairtax.org, a political forum

    Catapultam habeo. Nisi pecuniam omnem mihi dabris, ad caput tuum saxum immane mittam.

  3. #3
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    I dont know whether flash knows about octal numbers ... most languages would interpret something starting with 0 as an octal number, like they interpret something starting with 0x as a hex number. Now, 01099 is invalid in octal..

    Your best choice would be to treat zip codes as strings, and compare them like
    if(zip >= '01000' && zip <= '01099')

    Musicman.

  4. #4
    Senior Member
    Join Date
    Jan 2003
    Location
    @Home
    Posts
    104
    So I just need to enter my zip code range between "" and it will be treated as string??
    This is an example of what I need to do:
    01000-01099
    01500-01599
    20031-20090
    50054-60010
    [/B]
    If the entered zip code is within one of those range of zipcodes it means that the shipment can be deliverd within 24hs. What if the entered zipcode is not in those ranges??? How can I set an action to verify if the zipcode is not serviced within 24hs???
    I know that I can set somethin like:
    if (zipcode >=01000 && zipcode<=01099){
    message = "THE ZIP CODE YOU ENTERED IS WITHIN THE 24HS ZONE";
    }else if (zipcode >01099){
    message = "THE ZIP CODE YOU ENTERED IS NOT WITHIN THE 24HS ZONE";
    //and then start another range..
    IS THERE ANY EASIER WAY????
    ====================
    I love this forum!!!
    Pilot_22
    ====================

  5. #5
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    I would consider this way:
    Code:
    zips = [
     {from:'10000', to:'10099'},
     {from:'15000', to:'15099'},
    ...];
    ok = false;
    for(n = 0 ; n < zips.length ; n++)
      if(zip >= zips[n].from && zip <= zips[n].to)
      { ok = true;
        break;
      }
    if(ok) // customer gets fast service
    Musicman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center