I just started my first web design job and am a little confused. The company I am working for uses templates to design the e-commerce website. The developer is able to add more code to the templates to further customize the site. The templates seem to use VB for the most part with a little html and JavaScript mixed in. When I tried to call a function to a sql database its connected to with Java, it didnt recognize anything within the tags. From what research I've done, I'm guessing I need to do the tags like this:

<script type="text/javascript"><script language="javascript>


blah, blah, blah, blah

</script>

is this correct?

Member Avatar for iamthwee

is the javascript enabled?

<script type="text/javascript"><script language="javascript>
blah, blah, blah, blah
</script>
is this correct?

No.

You don't need two opening tags.

Either:

<script type="text/javascript" language="javascript">
blah, blah, blah, blah
</script>

or:

<script type="text/javascript">
blah, blah, blah, blah
</script>

because type=text/javascript means language=javascript (infact, language=javascript is not considered correct these days, perhaps due to redundancy, perhaps for another reason) it's technically correct to use both attributes on the same tag, it's not correct to place <script> tags inside one another.

ok, now I' really stumped. I've tried it with just the one tag like this and I can't get it to work.
<script type="text/javascript">blah, blah, blah, blah</script>So I guess I need to do a little more homework to see what I'm doing wrong. Do you know of any good books or links for me to look at?

What code are you actually executing? Perhaps there is an error in your code somewhere, or perhaps you're not calling the code at the right time/atall.

This site can be useful; it's certainly very beginner-orientated; and it's by the W3C, so you can assume you're learning the correct way so to speak.

http://www.w3schools.com/js/default.asp

Otherwise, look at things like where your script element is, and what needs to be loaded before the script can do its work.

This is that I am trying to get to execute. Another wird thing that I've noticed is that all the validation for the page is written in javascript and none if it is working. Its like all the java is being ignored. I'm just trying to fix what the last guy did before I started....... ahhhh!


<!--checks country code to see if the order is going to Latin America-->

<script type = "text/javascript" language = "javascript"
Dim strSelectedCountry = Request.Form("selCountry")

if strSelectedCountry == "Argentina" then
Orders placed for shipments going to Latin American countries will have a minimum 3 week lead time and additional freight charges will apply.
else
Test
end if
</script>

That's not JavaScript, it's VBScript.

it also looks like that should be executed on an ASP page (server application/script), rather than as client side script.

For client-side scripts, you do use the <script> etc </script> element, for server side scripts, you don't.

Both VBScript and Javascript can be used as client side scripting languges, AND used in ASP as the scripting language.. that seems quite confusing,

Think of a page in the browser as being one environment, and a page at the server as being in another enviornment... in those two environments there's a vast difference in what you can do, and how you do it.

You can use the same language in both environments, but it wont always have the same results, be used for the same reasons, or used in the same manner.

If that code was written like this:

<%
Dim strSelectedCountry = Request.Form("selCountry")
if strSelectedCountry == "Argentina" then
%>
Orders placed for shipments going to Latin American countries will have a minimum 3 week lead time and additional freight charges will apply.
<%
else
%>
Test
<%
end if
%>

it would be functional as a bit of (server-side) ASP script. Anything within <% %> pairs is treated as a block of ASP code, everything around <% %> pairs is treated as if it were output (text) data.

By the time ASP code reaches a browser, the server's already processed the ASP, and should have left 'clean' post-processed HTML; perhaps with some <script></script> elements containing client side script, which can then be run in a user's browser (usually, but not exclusivly, to add 'real time' interactivity to webpages)

The same piece of code cannot be written as client side VBScript or JavaScript in this circumstance, because it's dependant on the Request.Form ASP object, moreso it's dependant on form postdata (which isn't automatically propogated into a response)

You could use JavaScript as the ASP language; I'd say from a limited experience that ASP with VBScript is more documented than ASP with JavaScript; but you'd have to find out how true that is for your present situation.

You don't have to restrict yourself to one or other it's legal to use both scripting languages in ASP, and its legal to use a whole host of scripting languages client-side (but whether all browsers can deal with them, is another question entirely)

It works!! Thanks for being patient....This is what I did....I did it on accident really.......


<% if (objAddress.countryCode) = "AR" then

Response.write(" <font color=red size=2pt><b>Please Note: Orders placed for delivery to Latin American countries <br> will have a minimum 3 week lead time and additional shipping charges will apply")
end if
%>

Yep, that should work; the main difference is you've quoted the HTML and bought it into an ASP function.

I can't actually remember if ASP works like I think it does, so perhaps what I said about things outside <% %> being treated like output data (more importantly assuming that they're processed relative to the state of surrounding ASP script blocks) isn't correct, or perhaps it is..

It's quite important that you test/debug ASP code in an ASP environment... Testing on a live server, testing on a local server, or testing in an ASP debugger/emulator are all good bets... Loading the ASP page in your browser as if it were a file certainly wont work.

With client-side Javascript on the other hand; you can often test by opening a page from a file folder into your browser.

I hope you get the full hang of it. W3C have a few introductory pages to ASP coding on that w3cschools site; perhaps you might find them useful to..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.