•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 426,198 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,856 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1214 | Replies: 8 | Solved
![]() |
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
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?
<script type="text/javascript"><script language="javascript>
blah, blah, blah, blah
</script>
is this correct?
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation:
Rep Power: 5
Solved Threads: 48
•
•
•
•
<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.
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation:
Rep Power: 5
Solved Threads: 48
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 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.
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
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>
<!--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>
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation:
Rep Power: 5
Solved Threads: 48
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
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:
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 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
%>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)
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Feb 2007
Posts: 7
Reputation:
Rep Power: 0
Solved Threads: 0
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
%>
<% 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
%>
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation:
Rep Power: 5
Solved Threads: 48
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..
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..
If it only works in Internet Explorer; it doesn't work.
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Newb in Win Apps C# (Community Introductions)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Java based Itellitext
- Next Thread: random background generation: javascript



Linear Mode