A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Losing comma's

  1. #1
    Senior Member
    Join Date
    Sep 2002
    Location
    Clogland
    Posts
    100

    Losing comma's

    I'm trying to get details from athree FComboBoxes named "year", "month" and "day" and then insert the details into a MySql database in the "YYYYMMDD" format.

    The method I use below gets me an output of "YYYY,MM,DD".

    All I need to do is get rid of the comma's, but the "Strip" command as suggested by other threads here doesn't seem to work.

    I think I must be either missing a basic principle here, or have missed an easier way to go about it.

    TIA

    Code:
    dayValue=period.day.getValue();             //   Extracting values 
    monthValue=period.maand.getValue();         //   from drop down
    yearValue=period.jaar.getValue();           //   FComboBoxes
    
    //adding "0's" for entry into Mysql Database
    if(dayValue<10){
    	dayValue = "0" + dayValue;
    }
    if(monthValue<10){
    	monthValue = "0" + monthValue;
    }
    
    periodDate=[yearValue,monthValue,dayValue];  //   Making array
    
    NewPeriodDate = periodDate.split(",").join("");   // Doesn't work:confused:
    
    trace(periodDate);   	// returns YYYY-MM-DD
    trace(NewPeriodDate);   // returns "undefined"
    Last edited by skalie; 08-14-2003 at 05:12 AM.

  2. #2
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    Code:
    dayValue=period.day.getValue();             //   Extracting values 
    monthValue=period.maand.getValue();         //   from drop down
    yearValue=period.jaar.getValue();           //   FComboBoxes
    
    //adding "0's" for entry into Mysql Database
    if(dayValue<10){
    	dayValue = "0" + dayValue;
    }
    if(monthValue<10){
    	monthValue = "0" + monthValue;
    }
    
    periodDate=dayValue+monthValue+yearValue;  //   Making STRING
    What's wrong with this approach ... were you just complicating things for the sake of it, or am I missing something?
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  3. #3
    Senior Member
    Join Date
    Sep 2002
    Location
    Clogland
    Posts
    100
    What's wrong with this approach ... were you just complicating things for the sake of it, or am I missing something?
    Not for the sake of it, I'm just new to array syntax, and thanks.

    I did however just discover how do it the complicated way.....

    Code:
    //NewPeriodDate = periodDate.split(",").join("");   // Doesn't work
    
    NewPeriodDate = periodDate.join("");  // Works like a charm
    Fow what it's worth.

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