|
Thanks so much for your response, I fully intend on moving into the correct decade with .net, but i'm very new to web development and it's a bit of a learning curve even with ASP & Javascript. I will get there...
I have been through the code as you suggested and i'm still having problems, I simply need an asp recordset into a javascript array. Maybe i'm just too tired, but I just can't get it right.
Message: Object expected
Line: 14
Char: 1
Code: 0
URI: http://localhost/floorfurnishings/autocompleteactive1.asp
Line 14:
objRs_cmd.ActiveConnection = MM_floordb_STRING
<%@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">
<!--#include file="Connections/floordb.asp" -->
<%
Dim arrPDFs
Dim javascriptArrayValues
Dim objRs
Dim objRs_cmd
Dim objRs_numRows
Set objRs_cmd = Server.CreateObject ("ADODB.Command")
objRs_cmd.ActiveConnection = MM_floordb_STRING
objRs_cmd.CommandText = "SELECT * FROM dbo.Companies"
objRs_cmd.Prepared = true
Set objRs = objRs_cmd.Execute
objRs_numRows = 0
Function GetPDFsArray()
If NOT objRs.EOF OR NOT objRs.BOF Then
GetPDFsArray = objRs.GetRows()
Else
GetPDFsArray = ""
End If
End Function
'Get array
arrPDFs = GetPDFsArray
If isArray(arrPDFs) Then
for i=0 to uBound(arrPDFs,2)
javascriptArrayValues=javascriptArrayValues & """" & arrPDFs(0,i) & """" & ","
next 'i
javascriptArrayValues=Left(javascriptArrayValues,Len(javascriptArrayValues)-1)
Else
javascriptArrayValues = "Error: No results for array"
End If
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<%Response.Write(mySQL)%>
<input type="text" name="pdfDesc" id="pdfDesc" autocomplete="off" />
<script>
customarray = new Array(<%=javascriptArrayValues%>);
actb(document.getElementById("pdfDesc"),customarray);
</script>
</head>
<body>
</body>
</html>
<%
objRs.Close()
Set objRs = Nothing
%>
Thanks again.
|
|
|
|
|
Well, I can only assume thet the error on line 14 is related to something inside your include file "Connections/floordb.asp"....
Honestly, you will find it an easier learning curve to use ASP.NET. You can get all the development tools you need for free from here[^]. You will also find far more (useful) articles and help avaialable online.
[edit] btw, you have only closed the recordset, not the database connection (still).
|
|
|
|
|
... this is how I used to connect to databases using classic ASP:
Dim db, rs
Dim sql, r, i
' On Error Resume Next
Set db = Server.CreateObject("ADODB.Connection")
db.Open Application("dbConnect")
' Application("dbConnect") is database connection string, and defined in global.asa,
' but you can insert the connection string here isntead if you want
sql = "select ... whatever"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, db, 3, 1
' ... do whatever
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
used to work for me!
|
|
|
|
|
I can't believe it, when I re-wrote the page to clean it up I forgot to add the include files.... All working now.
Thanks again, and I will defiabtely look at .net.
Cheers,
Overtired Idiot.
|
|
|
|
|
Paul Hayman wrote: Overtired Idiot
We've all been there...
|
|
|
|
|
i want to show the percentage..but its not working plz tell the mistake
<html>
<head>
<script type="text/javascript">
function marksheet(sub1,sub2,sub3,sub4,sub5)
{
var sub_marks=parseInt(sub1)+parseInt(sub2)+parseInt(sub3)+parseInt(sub4)+parseInt(sub5);
var percentage=(sub_marks/500)*100;
return sub_marks;
if (percentage >= 50 && percentage <= 59)
{
document.write("You have got "C" Grade");
}
else if (percentage >= 60 && percentage <= 69)
{
document.write("You have got "B" Grade");
}
else if (percentage >= 70 && percentage <= 79)
{
document.write("You have got "A" Grade");
}
else (percentage >= 80 && percentage <= 100)
{
document.write("You have got "A+" Grade");
}
}
</script>
</head>
<body>
<script type="text/javascript">
var biology=prompt("Please enter marks of BIOLOGY", "");
var chemistry=prompt("Please enter marks of CHEMISTRY", "");
var pak_studies=prompt("Please enter marks of PAKISTAN STUDIES", "");
var sindhi=prompt("Please enter marks of SINDHI","");
var english=prompt("Please enter marks of ENGLISH","");
document.write("Total Marks Obtained Out Of 500 are: " + marksheet(biology,chemistry,pak_studies,sindhi,english));
</script>
</body>
</html>
|
|
|
|
|
The problem lies in the document.write statements where you write the grade out. You have unescaped quotes in there, so you need to escape them, e.g.:
document.write("You have got \"C\" Grade");
|
|
|
|
|
Is there not also a problem with the final "else ..if" clause? Can you have a qualifying statement on a (final) else clause without an "if" there? That last clause should be the catch-all, wihtout any qualifier... surely...? I can't see how his code will produce the desired output all the time...
|
|
|
|
|
You also need to return from your function after your if..else.. statement. Currently, the function will return without executing that portion. You will never get to your document.write statements.
|
|
|
|
|
Since you've already gotten some answers, I'll just point out a few items that may improve your coding. These are general solutions - the can be language and implementation specific.
For conversion to %, you'd (potentially) improve your accuracy by multiplying by 100 before dividing by 500. This is true if the math is done as integer math. The first division, by 500, will truncate values, which, when you multiply them, will be lost data. Although this is negligible in the this exact case, it can cause problems when the calculations aren't quite so clean. It is often the case (for floating point calcs) that multiplication by 0.1 is faster than division by 10.0.
Your many write() statements could be, perhaps, changed to assignments to a string, with only a single print statement. You could take it a step further and even simply assign a single letter to the string and use a formatted write() statement. Assignments are usually easier to understand (and have less internal overhead) than function calls. Again, you code is simple, but this could become a consideration as you create more complex apps. This also might be a matter of taste.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek dissappointment. If you are searching for perfection in yourself, then you seek failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
hi!
I uses javascript code for adding TR with respective TD on arrowKey press.
But my problem is that my code is working properly on IE but not work in Firefox.
I don't know why.
Please guide me on this.
thanx And regards,
|
|
|
|
|
Well if you want help you might start of by posting the code that isn't working as well as what firefox is reporting as errors in the error console.
Without that we can't do much, we aint mindreaders.
|
|
|
|
|
hi!
I want to add new cell in page through javascript.
my query is: when i press tab button and when tab button reaches on last cell , the new cell has been added
please help me.
thanx & regards
|
|
|
|
|
What have you got so far? When you say new cell, do you mean you want a new TR with relevant TD items in it? The basics of adding the row are covered here[^].
|
|
|
|
|
sir,
ya, this is my need. but in my last control is dropdownlist. when i press tab on ddl the new TR has been appeared with TD.
thanx
|
|
|
|
|
<html>
<body>
<a href = "http://www.hotmail.com" onmouseover="window.status = 'wanna goto hotmail';return true"
onmouseout = "window.status = '' ; return true"> hotmail</a>
</body>
</html>
what does 'return true' statement means here
|
|
|
|
|
without 'return true' its not wokring
|
|
|
|
|
It means that the function return s a value of true , hence return true;
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
My guess is so that you can use it in a variable. Its mandatory however.
|
|
|
|
|
It doesn't mean to return, you can delete the return statement
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
<html>
<body>
<script type="text/javascript">
var date = new Date();
var time = date.getHours();
if (time > 12 )
{
document.write("<b>Good Afternoon</b>");
}
if (time > 17 && < 24)
{
document.write("<b>Good Evening</b>");
}
else
{
document.write("<b>Good Morning</b>");
}
</script>
</body>
</html>
output is a blank page
|
|
|
|
|
if (time > 17 && < 24)
should be
if (time > 17 && time < 24)
(apart from which, as it is, it will write bnth Good Afternoon and Good Morning...)
May I suggest you use Firefox and open the error concole (Tools menu) - this will highlight such erros immediately and greatly help you in debugging your JavaScript code
|
|
|
|
|
I think the statement
if (time > 17 && < 24)
should read
if (time > 17 && time < 24)
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
thanks bro its working now
|
|
|
|
|
I have a page where I need to trigger a function (I'll call hideBox) when another function (which I will call unChecked) is triggered. So let's say unChecked is called when a checkbox is clicked, as soon as unChecked runs, I need hideBox to run as well. The catch here is that i do not have access to the .js that holds the code for unChecked, and even if I did, I know it is being used by several other pages and I can't risk messing them up in the process.
To further complicate things, I can't change any of the properties on the element that calls unChecked since the server side code is really picky about that sort of thing (the rest of the functionality breaks if I change any aspect of the input element. Needless to say, I did not write it.)
I have tried just binding the event with jQuery, but jQuery actually changes the attribute array in the DOM, which screws up the post-back behavior. I have done this exact thing before, but that was using prototype, which isn't an option here (and was for another company so I can't go back and see what I did).
Any ideas?
______________________
Oh Hamburgers!
|
|
|
|