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-17-2012, 08:21 AM   PM User | #1
b.eslami
New to the CF scene

 
Join Date: Apr 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
b.eslami is an unknown quantity at this point
Exclamation Display all "Digit Numbers" in webpage

Hi,
I want to when I open a web page , my program detect all the "digit numbers"
and display all of them for me.

I don't know exactly what do I do?

Thanks.
Regards.
b.eslami is offline   Reply With Quote
Old 04-17-2012, 08:24 AM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Detect? There is an infinite number of digit numbers ... where to detect? Where to show? What do you have?
devnull69 is offline   Reply With Quote
Old 04-17-2012, 09:14 AM   PM User | #3
b.eslami
New to the CF scene

 
Join Date: Apr 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
b.eslami is an unknown quantity at this point
Question

Quote:
Originally Posted by devnull69 View Post
Detect? There is an infinite number of digit numbers ... where to detect? Where to show? What do you have?
I want to display all digits in my web page
b.eslami is offline   Reply With Quote
Old 04-17-2012, 09:24 AM   PM User | #4
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
Sorry ... you cannot display all digits on one web page

EDIT: Aah digits ... decimal digits are only 0, 1, 2, .... 9 ... so it's easy to display them
Code:
for(i=0; i<10; i++) {
   document.write(i + "<br/>");
}
devnull69 is offline   Reply With Quote
Old 04-17-2012, 09:33 AM   PM User | #5
b.eslami
New to the CF scene

 
Join Date: Apr 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
b.eslami is an unknown quantity at this point
Quote:
Originally Posted by devnull69 View Post
Sorry ... you cannot display all digits on one web page

EDIT: Aah digits ... decimal digits are only 0, 1, 2, .... 9 ... so it's easy to display them
Code:
for(i=0; i<10; i++) {
   document.write(i + "<br/>");
}
thanks, but for example I have a page that character + decimal digits are, so I want to by javascrip select all decimal digits and display just them.
b.eslami is offline   Reply With Quote
Old 04-17-2012, 09:57 AM   PM User | #6
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
So you are on a page (your page) and you just want to extract all decimal digits and display them? But they are being displayed already ... where do you want to display them? Do you really mean digits or do you rather mean "full numbers"?
devnull69 is offline   Reply With Quote
Old 04-17-2012, 10:33 AM   PM User | #7
b.eslami
New to the CF scene

 
Join Date: Apr 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
b.eslami is an unknown quantity at this point
Quote:
Originally Posted by devnull69 View Post
So you are on a page (your page) and you just want to extract all decimal digits and display them? But they are being displayed already ... where do you want to display them? Do you really mean digits or do you rather mean "full numbers"?
all the numbers in that page
b.eslami is offline   Reply With Quote
Old 04-17-2012, 10:39 AM   PM User | #8
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
And the point of this is....?

Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
</head>

<script type="text/javascript" >

window.onload=function(){
var str = document.getElementsByTagName('html')[0].innerHTML;
//var str = document.getElementsByTagName('body')[0].innerHTML;  // string to be found must be in body
var x = str.match(/\d+/g);  // digits
alert (x);
}
</script>

12345
67890
98765

</body>
</html>
I take it that you do understand that you can only detect the digits appearing in your own page, and not some other web page.
__________________

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.

Last edited by Philip M; 04-17-2012 at 12:15 PM..
Philip M is offline   Reply With Quote
Reply

Bookmarks

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 03:12 AM.


Advertisement
Log in to turn off these ads.