User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Feb 2007
Posts: 7
Reputation: mosarie79 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mosarie79 mosarie79 is offline Offline
Newbie Poster

Help JavaScript Newbie

  #1  
Feb 25th, 2007
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,782
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 319
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: JavaScript Newbie

  #2  
Feb 25th, 2007
is the javascript enabled?
Last edited by iamthwee : Feb 25th, 2007 at 4:54 am. Reason: typo
I'm not a programmer. My attitude starts with ignorance, holds steady at conversation, and ends with a trip to the hospital. Get used to it.
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: JavaScript Newbie

  #3  
Feb 25th, 2007
<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.
Reply With Quote  
Join Date: Feb 2007
Posts: 7
Reputation: mosarie79 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mosarie79 mosarie79 is offline Offline
Newbie Poster

Re: JavaScript Newbie

  #4  
Feb 25th, 2007
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?
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: JavaScript Newbie

  #5  
Feb 25th, 2007
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.
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Feb 2007
Posts: 7
Reputation: mosarie79 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mosarie79 mosarie79 is offline Offline
Newbie Poster

Re: JavaScript Newbie

  #6  
Feb 26th, 2007
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>
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: JavaScript Newbie

  #7  
Feb 26th, 2007
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)
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Join Date: Feb 2007
Posts: 7
Reputation: mosarie79 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
mosarie79 mosarie79 is offline Offline
Newbie Poster

Re: JavaScript Newbie

  #8  
Feb 26th, 2007
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
%>
Reply With Quote  
Join Date: Jul 2006
Location: Deptford, London
Posts: 963
Reputation: MattEvans has a spectacular aura about MattEvans has a spectacular aura about 
Rep Power: 5
Solved Threads: 48
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Posting Shark

Re: JavaScript Newbie

  #9  
Feb 26th, 2007
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..
If it only works in Internet Explorer; it doesn't work.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 7:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC