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

Mixing javascript

Hi,
This code is in <head>. If I write this:

<script language="JavaScript" type="text/javascript">
<%
if (oRs.BOF && oRs.EOF )
%>
alert("hello");
</script>
....then the BOF/EOF methods are valid but the IF statement is not.
If I write this instead:
<script language="JavaScript" type="text/javascript">
if (oRs.BOF && oRs.EOF )
alert("hello");
</script>
....then the IF statement is valid but the BOF/EOF methods are not.

How can I fix this please? Thanks.
Feb 1 '08 #1
2 1760
groupie wrote on 02 feb 2008 in comp.lang.javascript:
>
I didn't know what <% %actually meant...thanks! I could also use
runat = 'server' ?
Whatever!

Under ASP that is not exactly the same.
I suppose I shouldn't have used 'alert' in my example - my main focus
was the IF statement and BOF/EOF. Valid statements are highlighted in
blue in dreamweaver when they are valid, and the BOF/EOF are
highlighted in pink.
Plesant dreams. Uding code you do not understand is always a bad idea, so
stop using dreamweaver and alike till you understand the code it produces,
and do your own coding till that time.
In my examples, I could only have the IF valid and BOF/EOF invalid, or
vice-versa, never both at the same time. I didn't really understand
why the <% %"tags" made things any different.
Valid?
How can If as a statement be invalid?
A better question is: Does it do wat you want it to do?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 2 '08 #2
groupie wrote:
This code is in <head>.
Actually, it is not. It is between <headand </head*server-side*. It
may be within <headand </headclient-side, too.
If I write this:

<script language="JavaScript" type="text/javascript">
Remove the deprecated `language' attribute, `type' suffices.
<%
if (oRs.BOF && oRs.EOF )
%>
alert("hello");
</script>
...then the BOF/EOF methods are valid but the IF statement is not.
<% ... %indicates ActiveServer Pages. The default programming language
in ASP is VBScript which syntax naturally differs from JScript (another
programming language that ASP supports).

Either

<%
If oRs.BOF And oRs.EOF
%>
window.alert("hello");
<%
End If
%>

or

<%@ LANGUAGE = "JScript" %>
<%
if (oRs.BOF && oRs.EOF)
{
%>
window.alert("hello");
<%
}
%>

should work (I recommend the latter, even if it means a rewrite). It would
generate

<script type="text/javascript">
window.alert("hello");
</script>

if the condition was met.
If I write this instead:
<script language="JavaScript" type="text/javascript">
if (oRs.BOF && oRs.EOF )
alert("hello");
</script>
...then the IF statement is valid but the BOF/EOF methods are not.
http://www.jibbering.com/faq/faq_not...ml#ps1DontWork
http://jibbering.com/faq/#FAQ4_43

`oRs' would be a reference to an object that exists server-side only.
I didn't know what <% %actually meant...thanks! I could also use
runat = 'server' ?
You could get a minimum clue before you start messing around with
(server-side) programming. There are plenty (online) resources out there,
including several about ASP, with the MSDN Library being not the least one.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Feb 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
1
by: Lloyd Sheen | last post by:
I am having big time problems seperating the two mention in subject line. I want to create a list of items (listbox or select) from a button click (on the server). The button click will ensure...
5
by: Shawn Repphan | last post by:
I have a webform with about 20 html textboxes and checkboxes. I am using ICallbackEventHandler to page through these successfully. But I need to be able to accept changes from these fields. How can...
7
by: Ubantu Rococo | last post by:
Hi all, Sorry for this stupid question, but I am having trouble mixing imagecopy etc. with HTML. What I am trying to do is copy an image, and then obtain co-ordinates from a database which will...
28
by: ziman137 | last post by:
Hello all, I have a question and am seeking for some advice. I am currently working to implement an algorithmic library. Because the performance is the most important factor in later...
8
by: brasilino | last post by:
Hi Folks: I'm trying to make a function from a inline script, which is called by <body'onload' event, calling an function in a external script, with no success. I'm using XHTML. I've tried many...
7
by: =?Utf-8?B?am9uZWZlcg==?= | last post by:
I'm hoping this is a classic question, but the answer to it would help me with a lot of things. As you can see below, this code will never display the "Getting data...." text in the lblCheck -...
3
by: Aussie Rules | last post by:
Hi. I am using Live Earth SDK, and have very little Javascript knowledge, but I need to insert values into a Javascript function, where the vales are in the ASP.net VB code. The javascript...
1
by: basm101 | last post by:
Hello, Firstly, apologies if this should be in the javascript forum - I wasnt sure which was most appropriate to post this question in... I am not sure if my problem is caused by the way I am...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.