Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checking entered value against Database Value ... best solution???

    I am currently checking two database values on different pages in different ways using javascript. Which way is best?

    Solution 1: I create a string of known values in JS as a variable (US zip codes). I then do a search on that string to see if the entered value is in the string. If the value is in the string, it's a good value and everything is OK. If it's not, the zipcode is invalid. The variable string is composed server side before presenting the page to the client browser using ColdFusion with a simple query of the database.

    Question on Solution 1: This list is rather large as the string is a comma seperated list of all the US zipcodes ... 42,489 of them! That's 254,934 characters (42,489 "," seperators & 42,489 5 character "strings")!!! Is there a limit to the size of a javascript string variable?

    Solution 2: Script on page 1 does some preliminary checking on the length and cofiguration of the string being entered. If this passes, it calls another function, which passes the string value to a ColdFusion page, which checks the database for the submitted value. If the value is found, the popup window closes and nothing happens because the value entered is valid (found in database). However, if the query returns 0 results, the popup window sends a call to a function on the parent window (the opener) and passes a result count of 0. The parent window function uses this value to determine if it will or will not throw an alert.

    Obviously, solution 2 is more complicated and involved, but works just fine. However, I like the smoothness (no popup windows) of the first solution. My problem is not knowing the limitations of javascript with regards to variable string length. Although the new string for Solution two would be smaller, both database tables have the ability to be updated periodically.

    Suggestions???

    Thanks!

  • #2
    Regular Coder
    Join Date
    Jan 2004
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I think I need to find a more graceful way of using the popup method. I did a little experiment and looked at the size of the page with the string variable in and without. 290KB with the test string and only 67.6KB without ... that is a huge difference. However, the page will only be used by 4-5 people as it's part of our intranet for a very specific need that only 4-5 people in the company use.


  •  

    Posting Permissions

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