%
'*************************************************************************
' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK!
' Function : Functions used for states and countries
' Product : CandyPress Store Frontend
' Version : 2.5
' Modified : February 2004
' Copyright: Copyright (C) 2004 CandyPress.Com
' See "license.txt" for this product for details regarding
' licensing, usage, disclaimers, distribution and general
' copyright requirements. If you don't have a copy of this
' file, you may request one at webmaster@candypress.com
'*************************************************************************
'*************************************************************************
'Variables
'*************************************************************************
dim countryArr
dim stateArr
'*********************************************************************
'Validate State & Country Code combination
'*********************************************************************
function validLoc(locState,locCountry)
dim mySQL, rsTemp
'Assume error until proven otherwise
validLoc = false
'Do basic checks
if len(locCountry) = 0 then
exit function
end if
'Do database checks
if len(locState) = 0 then
'Check if State/Province is required for the Country
mySQL = "SELECT COUNT(*) as recCount " _
& "FROM locations " _
& "WHERE locStatus = 'A' " _
& "AND locCountry = '" & validSQL(locCountry,"A") & "' "
set rsTemp = openRSexecute(mySQL)
if rsTemp("recCount") <= 1 then 'No states defined for Country
validLoc = true
end if
call closeRS(rsTemp)
else
'Check State/Country Combo is valid
mySQL = "SELECT locState " _
& "FROM locations " _
& "WHERE locStatus = 'A' " _
& "AND locState = '" & validSQL(locState,"A") & "' " _
& "AND locCountry = '" & validSQL(locCountry,"A") & "' "
set rsTemp = openRSexecute(mySQL)
if not rsTemp.EOF then 'Valid State/Country combo
validLoc = true
end if
call closeRS(rsTemp)
end if
end function
'*********************************************************************
'Create State / Province array
'*********************************************************************
function getStateArray()
dim mySQL,rsTemp
mySQL="SELECT a.locName,a.locCountry,a.locState " _
& "FROM locations a " _
& "WHERE a.locStatus = 'A' " _
& "AND NOT(a.locState IS NULL OR a.locState='') " _
& "AND EXISTS(SELECT b.idLocation " _
& " FROM locations b " _
& " WHERE b.locCountry = a.locCountry " _
& " AND b.locStatus = 'A' " _
& " AND (b.locState IS NULL OR b.locState='')) " _
& "ORDER BY a.locCountry,a.locName"
set rsTemp = openRSexecute(mySQL)
if not rsTemp.EOF then
stateArr = rsTemp.getRows()
end if
call closeRS(rsTemp)
end function
'*********************************************************************
'Create Country array
'*********************************************************************
function getCountryArray()
dim mySQL,rsTemp
mySQL="SELECT locName,locCountry " _
& "FROM locations " _
& "WHERE locStatus = 'A' " _
& "AND NOT(locCountry IS NULL OR locCountry='') " _
& "AND (locState IS NULL OR locState='') " _
& "ORDER BY locName"
set rsTemp = openRSexecute(mySQL)
if not rsTemp.EOF then
countryArr = rsTemp.getRows()
end if
call closeRS(rsTemp)
end function
'*********************************************************************
'Create drop-down list of States
'*********************************************************************
sub listStates(fieldName,fieldVal,fieldVal2)
dim row
if isArray(stateArr) then %>
<% end if
end sub
'*********************************************************************
'Create drop-down list of Countries
'*********************************************************************
sub listCountries(fieldName,fieldVal)
dim row
if isArray(countryArr) then %>
<% end if
end sub
%>