473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

how to obfuscated with asterisks

23
JavaScript Experts,

I have the following HTML. How could I use JavaScript such that when a user clicks on the checkbox in each row the phone numbers and e-mail addresses are partially obfuscated with asterisks?

Expand|Select|Wrap|Line Numbers
  1. <table><tr><form method='post'><td>phone:</td><td>21323</td><td width='10%' align='right'>mail:</td><td>bob@example.com</td><input name='submit' type='submit' value='check'><input type='hidden' name='nameid' value='6' ></form></tr></table> 
Dis question is asked to forwarded to javascript ... By Nicodemas in above format...
Am facing a problem, with this script...
I want two fields to be written by star , in order to hide . and this script does it , but ,
wat actually is my page opens directly with star letter , rather i need to open my page with the phoneno and email aftr clicking the button i want to make a change to the star to the respective fields ..........
How can i do this...

Page should open like ..
21323
dsad@dsa.com
check (button) aftr clicking

then
213***
ds**@*****

Expand|Select|Wrap|Line Numbers
  1. vbscript
  2.  function getPhone(text)
  3.  dim textsize
  4.  textsize = Len(text)
  5.  text = Left(text,5)
  6.  For index = 0 to textsize
  7.  text = text & "*"
  8.  Next
  9.  getphone = text
  10.  End Function
  11.  Function getEmail(text)
  12.  dim textsize
  13.  textsize =Len(text)
  14.  dim atpos
  15.  atpos = instr(text,"@") - 5
  16.  text = Left(text,5)
  17.  For index = 0 to textsize
  18.  if atpos = index+1 then
  19.  text = text & "@"
  20.  else
  21.  text = text & "*"
  22.  end if
  23.  Next
  24.  getemail = text
  25.  End Function
  26.  Set oConn = Server.CreateObject("ADODB.Connection")
  27.        Set oRs = Server.CreateObject("ADODB.Recordset")
  28.        oConn.Open "Provider=SQLOLEDB; Data Source = ria; Initial Catalog = northwind; Integrated Security = sspi;"
  29.   sSql =  "SELECT  phone,email,id FROM tbl1  userid =4 "
  30.    oRs.Open sSql, oConn
  31.       While not oRs.EOF
  32.  Response.write("<table><tr><form method='post'><td >phone : </td><td>"&getPhone(ors(0))&"</td><td width='10%'align='right'mail :</td><td>"&getEmail(ors(1))&"</td><input name='submit' type='submit' value='check'><input type='hidden' name='nameid' value='" & ors(2) & "' ></form></tr></table>")
  33.         oRs.MoveNext()
  34.      Wend
  35.      ors.close
  36.      oconn.close
  37.  if request.form("submit")="check" then
  38.  i=1
  39.  end if
  40.  if  request.form("nameid") <> "" then
  41.  set star1 = oConn.Execute("select resid from tbl1 where id= '" &request.form("nameid")&"'")
  42.  if not star1.eof then
  43.  sl = "UPDATE tbl1 SET star = '" & i & "' where resid= '" &request.form("nameid")&"' and userID = " & userid
  44.  oConn.Execute sl
  45.  End if
  46.  End if
  47.     %> 
  48.  
Jan 10 '09 #1
13 2257
acoder
16,027 Expert Mod 8TB
You'll need to use JavaScript rather than VBScript. Have you made a start on the JavaScript code?

PS. the [code] tags have numbered lines - there's no need to add them manually.
Jan 10 '09 #2
sureshl
23
But , i found one problem , that i couldn able to store the changes .

I mean this eg shows , (done by javascriipt)

Visualise this eg
Page open like this..
12332
sdfdf@dsdfs.com
Check (button) if clicked

Changes to dis
123****
sdf**@*****


But if i refresh the page,
it again change to
12332
sdfdf@dsdfs.com

so, am not able hold the obfuscated value , untill i change.....
i need to hold the obfuscated value....thats y i tried server side....
plz suggest..
Jan 10 '09 #3
acoder
16,027 Expert Mod 8TB
So, initially you want it displayed, but as soon as it's replaced by asterisks, it should remain that way?

If that's the case, you'll have to use server-side code. You can submit and change the database (or wherever the data is stored) so when you next refresh or display the page, the asterisks are there.

If you want to avoid a reload of the page when replacing, you can use Ajax.
Jan 10 '09 #4
sureshl
23
I dunno much about ajax . .

how can i do this... as my script ensures to make a obfuscated values .

but problem is , it directly opens directly with obfuscated values , i want to happen aftr clicking button , and have to be permanent untill i change...
Jan 10 '09 #5
acoder
16,027 Expert Mod 8TB
Should the "obfuscation" happen without reloading/unloading the page? If so, then Ajax it is, otherwise you only need server-side code. Let me know which it is.
Jan 10 '09 #6
sureshl
23
plz , U can tell me , how can i do it . .

Coz i need to hold the value of those obfuscated details . so, that i can see the values when i loaded again .

Thanks ...
Jan 10 '09 #7
acoder
16,027 Expert Mod 8TB
Here's a link to help get you started. Post back if you get stuck.
Jan 10 '09 #8
sureshl
23
This is what i understood, Am i right with these things..?

Yes . ajax is one which supports latest browsers where any functions can be called by javascript , and the functions status can be checked by readystate function , so whether the connection is success or not

So, aftr these steps, We have two options to do our need ,
Responsetext--> Some Text
Responsexml-->some xml documents travering by javascript functions..

Need some more clarity in Open, send ....
Jan 12 '09 #9
Dormilich
8,658 Expert Mod 8TB
@sureshl
open() is comparable to the (HTML) form element, while send() is starting the http request (sending the variables)

see XMLHttpRequest – MDC

regards
Jan 12 '09 #10
sureshl
23
This is my first ajax code...Okay , For my issue ,
I converted my vbscript to javascript , Is my coding is correct , Now i need to work such a way to convert my clear text to obfuscated values . .


Expand|Select|Wrap|Line Numbers
  1. function makeRequest(url) {
  2.         var httpRequest;
  3.  
  4.         if (window.XMLHttpRequest) { // Mozilla, Safari, ...
  5.             httpRequest = new XMLHttpRequest();
  6.             if (httpRequest.overrideMimeType) {
  7.                 httpRequest.overrideMimeType('text/xml');
  8.                 // See note below about this line
  9.             }
  10.         } 
  11.         else if (window.ActiveXObject) { // IE
  12.             try {
  13.                 httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
  14.             } 
  15.             catch (e) {
  16.                 try {
  17.                     httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  18.                 } 
  19.                 catch (e) {}
  20.             }
  21.         }
  22.  
  23.         if (!httpRequest) {
  24.             alert('Giving up :( Cannot create an XMLHTTP instance');
  25.             return false;
  26.         }
  27.         httpRequest.onreadystatechange = function() { getphone(text); getemail(text); };
  28.         httpRequest.open('GET', url, true);
  29.         httpRequest.send('');
  30.  
  31.     }
  32.  
  33.     /*function alertContents(httpRequest) {
  34.  
  35.         if (httpRequest.readyState == 4) {
  36.             if (httpRequest.status == 200) {
  37.             <!--alert(httpRequest.responseText);-->
  38.             } else {
  39.                 alert('There was a problem with the request.');
  40.             }
  41.         }*/
  42.         function getPhone(text)
  43.           {
  44.            if (httpRequest.readyState == 4)
  45.             {
  46.             if (httpRequest.status == 200) 
  47.             {
  48.               var textsize 
  49.               textsize = Len(text)
  50.               text = Left(text,5)
  51.               For (index = 0 ;index <=textsize ; index++)
  52.               {
  53.               text = text & "*"
  54.               }
  55.               getphone = text
  56.             }
  57.             else 
  58.             {
  59.                 alert('There was a problem with the request.');
  60.             }
  61.             }
  62.  
  63.             function getEmail(text)
  64.             {
  65.             if (httpRequest.readyState == 4)
  66.             {
  67.             if (httpRequest.status == 200) 
  68.             {
  69.             var textsize
  70.             textsize =Len(text)
  71.             var atpos
  72.             atpos = instr(text,"@") - 5
  73.             text = Left(text,5)
  74.             for(index = 0 ; index<=textsize ; index ++ )
  75.             {
  76.             if atpos = index+1 then
  77.             text = text & "@"
  78.             }
  79.             else
  80.             {
  81.             text = text & "*"
  82.             }
  83.             }
  84.             getemail = text
  85.             }
  86.             </script>
If the above code is correct , how can i call this ajax script in my code ,

Expand|Select|Wrap|Line Numbers
  1. Set oConn = Server.CreateObject("ADODB.Connection")
  2.         Set oRs = Server.CreateObject("ADODB.Recordset")
  3.         oConn.Open "Provider=SQLOLEDB; Data Source = ria; Initial Catalog = northwind; Integrated Security = sspi;"
  4.    sSql =  "SELECT  phone,email,id FROM tbl1  userid =4 "
  5.     oRs.Open sSql, oConn
  6.        While not oRs.EOF
  7.   Response.write("<table><tr><form method='post'><td >phone : </td><td>"&getPhone(ors(0))&"</td><td width='10%'align='right'mail :</td><td>"&getEmail(ors(1))&"</td><input name='submit' type='submit' value='check'><input type='hidden' name='nameid' value='" & ors(2) & "' ></form></tr></table>")
  8.          oRs.MoveNext()
  9.       Wend
  10.       ors.close
  11.       oconn.close
Jan 12 '09 #11
acoder
16,027 Expert Mod 8TB
Before we go any further, the only benefit Ajax would provide here is that the "obfuscation" would take place almost instantly without having to submit a form and unloading the page. If that's not important, Ajax is not necessary and you can simply submit the form to a server-side page (code you already have) and display the values with parts replaced by asterisks.
Jan 12 '09 #12
sureshl
23
Now my present code and Problem i had explained....
my below retreives only first data...i mean only this...
12343 dsf@sd.ds ,
i want to retrieve all the data, for those uservalue has id =1

My db :
tbluser
uservalue id
2 1
3 1
4 1
5 1
and using this uservalue it rerieves phone, email from this table
tblstudent
phone email uservalue
12343 dsf@sd.ds 2
123231 dsf@ds.df 3
123231 sfd@dfs.ds 4

Expand|Select|Wrap|Line Numbers
  1. set chk =oConn.execute("select uservalue from tbluser where id = 1")  
  2.   if not chk.EOF then
  3.    id  =chk("uservalue")
  4.     sSql =  "SELECT  phoneno,email,id FROM tblstudent where  uservalue = " & id 
  5.     oRs.Open sSql, oConn
  6.        While not oRs.EOF 
  7.        Response.write("<table><tr><form method='post'><td >phone : </td><td>" & getphone(ors(0)) & "</td><td width='10%'align='right'mail :</td><td>"& getEmail(ors(1)) &"</td><input name='submit' type='submit'  value='check'><input type='hidden'  name='nameid' value='" & ors(2) & "' ></form></tr></table>")
  8.        oRs.MoveNext()
  9.     Wend
  10. end if
  11.   if request.form("submit")="check" then
  12.   i=1
  13.   end if
  14.   if  request.form("nameid") <> "" then
  15.   set star1 = oConn.Execute("select resid from tbl1 where id= '" &request.form("nameid")&"'")
  16.   if not star1.eof then
  17.   sl = "UPDATE tbl1 SET star = '" & i & "' where resid= '" &request.form("nameid")&"' and userID = " & userid
  18.   oConn.Execute sl
  19.   End if
  20.   End if
  21.  
Jan 12 '09 #13
acoder
16,027 Expert Mod 8TB
Your best bet for that would be the ASP forum. If you do decide to grapple with Ajax again, you can come back to this thread.
Jan 12 '09 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: fix | last post by:
Hello, i need to protect my xsl file. In my xsl i have a mechanism for defining a personal stylesheet, what i want to do is, if it possible, find a mechanism for Obfuscated the xsl source code ....
22
by: Kim Scarborough | last post by:
Say I wanted to put a couple lines of asterisks between paragraphs, and have it stretch the spaces so that it spanned 100% of the text-width, like this: * * * * * ...
2
by: Steve | last post by:
I'd like to create a form where required fields are marked by asterisks. The asterisks would then disappear as the field or checkbox is filled in by the user. If there's a way to do this with...
1
by: assaf | last post by:
hi all i am using PreEmptive Solutions dotfuscator (community edition). and i am getting 'TypeLoadException' for a simple interface that i defined. how can i debug an obfuscated application? ...
3
by: Susan Bricker | last post by:
I would like to have a transparent command button on my Main Menu to cause an Inputbox( ) to be displayed for the user to enter a password. This is to control the enabling of Bypass Key (shift). ...
4
by: Paul E Collins | last post by:
For those who appreciate such things, here's a bit of obfuscated C# I knocked up in a spare moment at work. http://CL4.org/comp/jabberwocky.txt P. -- www.CL4.org
5
by: Kahlia | last post by:
Hi. I am trying to print a pyramid of asterisks using recursion so that the recursive function takes in an integer and prints that number of lines of asterisks and then reverses, eg: * ...
14
by: D.M. Procida | last post by:
In music (apparently) when listing a composer's compositions, a single asterisk against a performance item denotes that it is a premiere (i.e. in that country), and two asterisks that it is a world...
12
by: ab12 | last post by:
I'm trying to write a program in C that gets a shape outlined with asterisks from the user, and returns that shape filled with asterisks. It will also get the coordinates of a point inside the shape...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.