oleooo Posted August 23, 2011 Share Posted August 23, 2011 I am trying to get a drop down to allow me to also just type in amount with out it formating with the Number label. For Example I have a drop down with Toll free (800), etc, Then I have a phone rule Var1="Cell"; CaseSelection="Format 2"; if(CaseSelection == "Format 1") { var formatStyle01 = "$1.$2"; //simple 7 digit phone var formatStyle02 = "$1.$2.$3"; //simple 10 digit phone var formatStyle03 = "+$1 $2.$3.$4"; //10 digit phone starts with 1 var formatStyle04 = "$1.$2.$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 $2.$3.$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1.$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } if(CaseSelection == "Format 2") { var formatStyle01 = "C $1-$2"; //simple 7 digit phone var formatStyle02 = "C $1-$2-$3"; //simple 10 digit phone var formatStyle03 = "C +$1 $2-$3-$4"; //10 digit phone starts with 1 var formatStyle04 = "C $1-$2-$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "C +$1 $2-$3-$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "C $1-$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } if(CaseSelection == "Format 3") { var formatStyle01 = "$1-$2"; //simple 7 digit phone var formatStyle02 = "($1)$2-$3"; //simple 10 digit phone var formatStyle03 = "+$1 ($2)$3-$4"; //10 digit phone starts with 1 var formatStyle04 = "($1)$2-$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 ($2)$3-$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1-$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } if(CaseSelection == "Format 4") { var formatStyle01 = "$1.$2"; //simple 7 digit phone var formatStyle02 = "($1)$2.$3"; //simple 10 digit phone var formatStyle03 = "+$1 ($2)$3.$4"; //10 digit phone starts with 1 var formatStyle04 = "($1)$2.$3 ext.$4"; //10 digit phone with extension var formatStyle05 = "+$1 ($2)$3.$4 ext.$5"; //10 digit phone starts with 1 with extension var formatStyle06 = "$1.$2 ext.$3"; //7 digit phone with extension var thisNumber = Field(Var1); return formatNumber(Trim(thisNumber)); } ////////////////////////////////////////////////////////////////////////////////////////////////////// // DO NOT EDIT BELOW THIS LINE /////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////// return formatNumber(Trim(thisNumber)); function formatNumber(number01){ var pattern01 = /^(\d{3})[^\d]*(\d{4})$/; // //2201727 or 220-1727 or 220- 1727 var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; // 8002201727 or 800-220-1727 or (800)220-1727 or (800) 220-1727 var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/; // 18002201727 or 1-800-220-1727 or +1 (800) 220-1727 var pattern04 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 800-220-1727 ext 12345 or (800) 220-1727 ext 12345 var pattern05 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 1-800-220-1727 ext 12345 or +1 (800) 220-1727 ext 12345 var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; // 2201727 ext 1234 or 220-1727 ext 1234 or 220- 1727 ext 1234 var patternEndExt = /(.)[x#n](.)/; var patternStart1 = /^[\D]*[1]/; if(number01.match(pattern01)){ number01 = number01.replace(pattern01, formatStyle01); return number01; } else if(number01.match(pattern02)){ number01 = number01.replace(pattern02, formatStyle02); return number01; } else if(number01.match(pattern03)){ if (number01.match(patternStart1)){ number01 = number01.replace(pattern03, formatStyle03); return number01; } else { return number01; } } else if(number01.match(pattern04)){ number01 = number01.replace(pattern04, formatStyle04); return number01; } else if(number01.match(pattern05)){ number01 = number01.replace(pattern05, formatStyle05); return number01; } else if(number01.match(pattern06)){ number01 = number01.replace(pattern06, formatStyle06); return number01; } else { //return "no match any pattern"; return number01; } } My problem is when I put in the Dropdown (Toll Free(800)) it shows up as such Toll Free (800) C 345-2564. I need it not to show the c when the drop down is used. I tried a Conditional rule: if Field(Cell) = ""; Return Field(dropdown)+Rule(NoPhoneC); else Return Rule(cellformateRule); But of it did not work. Is there any hope for me. Thanks Ole Link to comment Share on other sites More sharing options...
Dan Korn Posted August 23, 2011 Share Posted August 23, 2011 Instead of modifying the Change phone format rule to add the "C" prefix every time, I would go back to the default Change phone format rule, and use another rule to conditionally add the "C" prefix. Something like this: if (Int(Field("Dropdown")) == 0) return "C " + Rule("Change phone format Rule") // else return Field("Dropdown") + Rule("Change phone format Rule") It's hard to give more specific advice without seeing your job, or at least your data. Link to comment Share on other sites More sharing options...
oleooo Posted August 23, 2011 Author Share Posted August 23, 2011 Dan I have uploaded the sample I am working on. The C was still showing up behind the Toll Free (800). Not sure how to resolve it. But I hope the files help. Thanks OleHS Business Card.zip Link to comment Share on other sites More sharing options...
jwhittaker Posted August 24, 2011 Share Posted August 24, 2011 oleooo Is the "C 208" going to be in your drop down? It's in your data file. What is your drop down going to have in it? I created new rules a different way that might help. It's not a optimized as Dan, the programming master, would be. I'm still a hacker, but this is how I would do it. Check out the rules with NEW on the front of the rule name. JonNEW HS Business Card.zip Link to comment Share on other sites More sharing options...
oleooo Posted August 24, 2011 Author Share Posted August 24, 2011 Jon, The drop down will have the C 208 in it as well as Toll Free (800) and Spectralink (800). my main problem is that when I go to use Toll Free from dropdown it also puts in the C. Which I do not want. it looks like this Toll Free (800) C 371-9041 Thanks Ole Link to comment Share on other sites More sharing options...
jwhittaker Posted August 24, 2011 Share Posted August 24, 2011 Ole If you swop out this in the NEWcellRule, it will put in the drop down and then the number. Check your data for the toll-free number and make sure the C isn't in there. The one record you send only had a cell number not a toll-free. If this doesn't work, send a record using the toll-free that not working. return Field("Dropdown") + " " + formatNumber(Trim(thisNumber)); Link to comment Share on other sites More sharing options...
oleooo Posted August 24, 2011 Author Share Posted August 24, 2011 Jon, It looks like that will work. Thanks so much for the help. Ole Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.