js file connecting to db. mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
<?erick?>
Forum Newbie
Posts: 12
Joined: Thu May 29, 2008 8:36 am

js file connecting to db. mysql

Post by <?erick?> »

Code: Select all

 
function FillCountry(cboCountry, cboState, sDefaultCountry){
    var sDefaultCountry, sDefault, sCountry
        
    cboCountry.options.length=0
    for(i=0;i<sCountryString.split("|").length;i++){
        sCountry = sCountryString.split("|")[i];
 
        if (sDefaultCountry == sCountry) {
            sDefault=true;
            if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
        }
        else {sDefault=false;}
        
        if (sDefault) {cboCountry.options[i]=new Option(sCountry,sCountry,sDefault,sDefault);}
        else {cboCountry.options[i]=new Option(sCountryString.split("|")[i]);}
    }
}
if (navigator.appName=="Netscape"){
isNav=true
}
 
function FillState(cboCountry, cboState, sDefaultState){
    var sDefaultState, sState, sDefault
        
    cboState.options.length=0
    for(i=0;i<sStateArray[cboCountry.selectedIndex].split("|").length;i++){
        sState = sStateArray[cboCountry.selectedIndex].split("|")[i];
        
        if(sDefaultState == sState) {
            sDefault=true;
            if (navigator.appName=="Microsoft Internet Explorer"){cboState.focus();}
        } 
        else {sDefault=false;}
        
        if(sDefault) {cboState.options[i]=new Option(sState,sState,sDefault,sDefault)}
        else {cboState.options[i]=new Option(sState,sState);}
    }
}
 
 
 
var sCountryString ="|Afghanistan|Albania|Algeria|American Samoa|Angola|Anguilla|Antartica|Antigua and Barbuda|Argentina|Armenia|Aruba|Ashmore and Cartier  Island|Australia 
 
 
my question is it is possible the var sCountryString get a data "from mysql data base" instead to static..
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: js file connecting to db. mysql

Post by nowaydown1 »

In a roundabout way, yes. Just have PHP write out your javascript variable dynamically using the result set from your database.
Post Reply