Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-10-2012, 10:27 PM   PM User | #1
cheaven
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
cheaven is an unknown quantity at this point
displaying javascript result in column

using a javascript function to determine if a string is all digits or not and return result based off the decision. if it is all digits, mask all digits except the first two, if not all digits just return the string.

these are the snippets however i am not seeing anything returned in the column

Code:
<script >


var start = function RenderRC(CodeOwner) {

        var Rcode = CodeOwner.toString();

        var pattern = new RegExp("^\d{2,}$ ");

        if (Rcode.match(pattern)) {

            if (Rcode.length > 2)
             {
                var newcode = Rcode.substr(0, 2) + Array(Rcode.length - 2 + 1).join("*");
                return newcode;
            }

        }
          else 
        {
               return Rcode; 
        }
        
    };

</script>

 <ext:RecordField Name="CodeOwner" />


 <ext:Column Header="<%$ Resources:Text, CodeOwner %>"DataIndex="CodeOwner" Width="110" >
                <Renderer Fn ="start" />
                </ext:Column>
cheaven is offline   Reply With Quote
Old 04-10-2012, 10:49 PM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,460
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
What does the HTML look like?
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is online now   Reply With Quote
Old 04-11-2012, 07:57 AM   PM User | #3
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,043
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Code:
<script type = "text/javascript"> 

function a(str) {
if (/\D/gi.test(str)) {
return str;  // non-digits found
}
var len = str.length;
var newstr = str.substring(0,2);
var rest = str.substring(2);
rest = rest.replace(/\d/g,"*");
newstr += rest;
return newstr;
}

alert  (a("1234567"));

</script>

If he'd had a clear view I think he would have seen it. - Commentator Sky Sports 1
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 04-11-2012, 03:36 PM   PM User | #4
cheaven
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
cheaven is an unknown quantity at this point
thanks so far, but i am still not sure how to return it to have it displayed in the column...
cheaven is offline   Reply With Quote
Old 04-11-2012, 03:57 PM   PM User | #5
cheaven
New to the CF scene

 
Join Date: Apr 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
cheaven is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
Code:
<script type = "text/javascript"> 

function a(str) {
if (/\D/gi.test(str)) {
return str;  // non-digits found
}
var len = str.length;
var newstr = str.substring(0,2);
var rest = str.substring(2);
rest = rest.replace(/\d/g,"*");
newstr += rest;
return newstr;
}

alert  (a("1234567"));

</script>

If he'd had a clear view I think he would have seen it. - Commentator Sky Sports 1

thanks so far but i still not having anything returned to the column, is that what the "alert" is for?
cheaven is offline   Reply With Quote
Old 04-11-2012, 04:56 PM   PM User | #6
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,043
Thanks: 197
Thanked 2,412 Times in 2,390 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by cheaven View Post
thanks so far but i still not having anything returned to the column, is that what the "alert" is for?
No,the alert is simply for test/demonstration purposes. As felgall says, we need to see the (relevant) HTML code before we can go any further.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Tags
asp, html, javascript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:58 AM.


Advertisement
Log in to turn off these ads.