473,387 Members | 1,863 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,387 software developers and data experts.

Invalid procedure call or argument: 'Left'

23
Page opens like this....
phone:123243453
email:henria@real.com

but aftr clicking that button

I need to display like this..
phone:12324****
email:hen***@******

am geting this eror...
Invalid procedure call or argument: 'Left'

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function doSwitch(thePhone, theMail, theIndex){

document.poppedLayer = eval('document.getElementById("phone"+theIndex)');
document.poppedLayer.innerText=thePhone+"****";
document.poppedLayer = eval('document.getElementById("email"+theIndex)');
document.poppedLayer.innerText=theMail+"@****";
}
</script>
</head>

<body>

<%
Dim oconn, rs, sql, tempCount
Set oConn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
oConn.Open "Provider=SQLOLEDB; Data Source = Asdaf; Initial Catalog = northwind; Integrated Security = sspi;"

sql = "select phoneno, email from table1"
set rs = Server.CreateObject("ADODB.Recordset")
set rs = oconn.execute(sql)

tempCount = 1
Response.Write("<form name=""myForm"" action=""test.asp"" method=""post""><table id=""myTable""><tr><td>Phone Number</td><td>Email Address</td><td>&nbsp;</td></tr>")
While not rs.EOF

Response.Write("<tr><td id=""phone" & tempCount & """>" & rs.Fields(0) & "</td><td id=""email" & tempCount & """>" & rs.Fields(1) & "</td><td><input type=""button"" onclick=""doSwitch('" & Left(rs.Fields(0), 5) & "','" & Left(rs.Fields(1), InStr(rs.Fields(1), "@")-1) & "','" & tempCount & "')"" value=""Mask""></tr>")
tempCount = tempCount + 1
rs.MoveNext

Wend
Response.Write("</table></form>")
rs.Close
cn.Close
%>
</body>
</html>
Jan 8 '09 #1
1 6870
Nicodemas
164 Expert 100+
Your code is very hard to read. Please make sure you post code inside of code tags (in the editing bar above the input field for your message).

It seems like one of the arguments you are feeding the Left() function is not returning the value you expect, e.g. your recordset might be returning a NULL value, or your InStr() is returning a NULL or negative value. Either of these incidents would cause your Left() to throw an error.

I would suggest debugging your code by ensuring the values you insert into the function are returning the result you expect. Do so by using a few lines of code, and comment out the production stuff.

Example (broken onto many lines for read-ability):

Expand|Select|Wrap|Line Numbers
  1. while not rs.eof
  2.    'response.write "<tr>"
  3.    'response.write "<td id='phone" & tempCount & "'>" & rs.Fields(0) & "</td>"
  4.    'response.write "<td id='"& email" & tempCount & "'>" & rs.Fields(1) & "</td>"
  5.    'response.write "<td><input type='button' onclick=""doSwitch('"& Left(rs.Fields(0), 5) &"', '"& Left(rs.Fields(1), InStr(rs.Fields(1), "@")-1) &"', '"& tempCount &"')"" value='Mask'>"
  6.    'response.write "</tr>"
  7.    'tempCount = tempCount + 1
  8.    response.write "rs(0) = "& rs.Fields(0) & " and rs(1) = " & rs.Fields(1) & "<br />"
  9.    response.write "InStr(rs.Fields(1), "@")-1) = "& InStr(rs.Fields(1), "@")-1) & "<hr />"
  10.    rs.MoveNext
  11. Wend
  12.  


Which should output something like this per iteration:

rs(0) = 888-555-1234 and rs(1) = bob@example.com
InStr(rs.Fields(1), "@")-1) = bob
If the output isn't what you expect, then you've found a problem. My biggest suspicion is that the InStr() isn't returning what you expect.
Jan 8 '09 #2

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

Similar topics

6
by: mork | last post by:
I am so frustrated - any help is appreciated. When trying to use common functions like Left and/or Mid I get the following error: Run-time Error '5': Invalid Procedure Call or Argument In my...
6
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
5
by: Mariame | last post by:
Hi All, I have a datagrid in the select button i write the following code: Response.Write("<script>window.open('new.aspx', New Page',...
5
by: Matt | last post by:
I am receiving the following error from the simple script below. This works fine from a .NET form but when I access the dll from a Classic ASP page it fails. Microsoft VBScript runtime error...
5
by: Eric | last post by:
I run a program which read emails from a text file. There is some thing invalid in one or more text file. When program is busy doing parsing it shows that error and process stop. I dont know which...
1
by: Eric | last post by:
When I run my script it gives error on the following line: strEmail = Right(strEmail, (Len(strEmail) - 1)) I enclose my code and the sample text file too Thanks,...
5
by: wpellett | last post by:
I can not get the SQL compiler to rewrite my SQL UPDATE statement to include columns being SET in a Stored Procedure being called from a BEFORE UPDATE trigger. Example: create table...
6
by: HaggardSmurf | last post by:
Private Sub Downloader1_DownloadComplete(MaxBytes As Long, SaveFile As String) If MsgBox("Donwnload Finished. Would you like to install now?", vbInformation + vbYesNo, "Blue Cherry Media...
25
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.