473,783 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mixing javascript

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

<script language="JavaS cript" 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="JavaS cript" 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 1775
groupie wrote on 02 feb 2008 in comp.lang.javas cript:
>
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="JavaS cript" 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("h ello");
<%
End If
%>

or

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

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

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

if the condition was met.
If I write this instead:
<script language="JavaS cript" 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
5078
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 they press "Cancel" they call another ASPX function. My code now is: System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf) System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
1
1099
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 that all data required for viewing the page is within the page and after that selecting items from the table should cause client processing to modify the look of the page. The server code is easy. I access data on the server and add it to the...
5
1526
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 I access an html field from ASP.net? Or better yet, how do I access server controls from javascript? The latter would be possible if ASP.net always gives the textboxes the excat same ID.
7
2670
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 then be drawn on the image (to create a clickable imagemap). The image will then be displayed as part of a webpage. I've included my code snippet below. It doesn't work, and I think I know why - the output on my screen
28
3102
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 applications, I decide to write it in C instead of C++. However, I thought it might be convenient to use some C++ code at some misc places. I'm aware that, I could always use the C++ compiler to get it work.
8
1855
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 ways.... Here comes the snippet (without XML prolog and DOCTYPE declaration): <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
7
1540
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 - because it needs to do a round-trip to the server - first. And when it gets back, my other routine will over-write the text as "34 records found" Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
3
1695
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 function is below, but I need to replace the value (47.6, -122.33) with variables in the code behind page that I get from my SQL 2000 database.
1
2216
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 mixing java and javascript in my jsp and if it can be fixed. If currentObservation.getComment() (java) is not null then all is well. But if it is null, instead of just setting document.commentForm.commentBox.value to a blank string I get a...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.