PDA

View Full Version : adding to a number



marringi
04-28-2008, 03:39 PM
I'm using a small script that fetches a word from the location and displays it onto the page. I'm using numbers in this and I'm wondering if it is possible to modify the script so that it would write down the number from the location and then also a new number next to it, a number that is the original number + 1.

Lets say that the location of the web is file.html?number=32.

Then into the page would be written: 32_33

Here is the script that I'm using:


function numbers()
{
var paramValue;
if( paramValue=window.location.search.match(/[?&]number=(\w+)/) )
document.write( paramValue[1] );
}


Any ideas if this is possible and if so, how?

jscheuer1
04-28-2008, 05:37 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</head>
<body>
<script type="text/javascript">
;(function(){ var num, gq = function(n) {
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=location.search;
return (m=r.exec(m))? unescape(m[1]) : null;}; if(!isNaN((num=
parseInt(gq('number')))))document.write(num++ + '_' + num);})();
</script>
</body>
</html>