catchup
11-05-2003, 01:58 PM
I was wondering if it was possible to do what the ASP does client side. I have 2 text boxes on the page that i am entering ip address ranges in like: 164.248.0.1 - 164.248.0.171
I need to conver the ips to a number so i can compare another convert numbered ip to see if it is in that particular range. The ASP below converts the dotted ip to a number:
ipno =Dot2LongIP("rangeBegin")
ipno2 =Dot2LongIP2("rangeEND")
function Dot2LongIP (DottedIP)
If DottedIP = "" Then
Dot2LongIP = 0
Else
For i = 1 To 4
pos = InStr(PrevPos + 1, DottedIP, ".", 1)
If i = 4 Then
pos = Len(DottedIP) + 1
End If
num = Int(Mid(DottedIP, PrevPos + 1, pos - PrevPos - 1))
PrevPos = pos
Dot2LongIP = ((num Mod 256) * (256 ^ (4 - i))) + Dot2LongIP
Next
End If
End function
function Dot2LongIP2 (DottedIP2)
......
End function
// I'm hoping to cut n paste the range begin and range end into the rangeBegin and rangeEnd text fields and have the JS function convert the dotted ips to a number that i could use math operators like < and > to see if an ip is in its range, ofcourse i'm using a database and blah blah...
Thanks
I need to conver the ips to a number so i can compare another convert numbered ip to see if it is in that particular range. The ASP below converts the dotted ip to a number:
ipno =Dot2LongIP("rangeBegin")
ipno2 =Dot2LongIP2("rangeEND")
function Dot2LongIP (DottedIP)
If DottedIP = "" Then
Dot2LongIP = 0
Else
For i = 1 To 4
pos = InStr(PrevPos + 1, DottedIP, ".", 1)
If i = 4 Then
pos = Len(DottedIP) + 1
End If
num = Int(Mid(DottedIP, PrevPos + 1, pos - PrevPos - 1))
PrevPos = pos
Dot2LongIP = ((num Mod 256) * (256 ^ (4 - i))) + Dot2LongIP
Next
End If
End function
function Dot2LongIP2 (DottedIP2)
......
End function
// I'm hoping to cut n paste the range begin and range end into the rangeBegin and rangeEnd text fields and have the JS function convert the dotted ips to a number that i could use math operators like < and > to see if an ip is in its range, ofcourse i'm using a database and blah blah...
Thanks