From: joy99 on
Dear Group,

I am bit new in this group, so with Java Script.

I was reading some early tutorials on it.

My questions are:

(i) Suppose I write
<script type="text/javascript">
x="My Name"
document.write("<h1>x</h1>);
</script>

would it show the result i.e., the string value of x in header 1?
If not, how can I display the font values to my declared variables?

Is there any good URL to practice/learn on this topic?

(ii) Can I combine CSS with JScript?
If anyone can give me one/two basic examples, a good URL to learn on
my own is obviously better.

(iii) Though Java and Javascript are hugely different but do they have
any similarity in syntax?

Wishing you a happy day ahead,
Best Regards,
Subhabrata.
From: David Mark on
joy99 wrote:
> Dear Group,
>
> I am bit new in this group, so with Java Script.

Javascript (one word).

>
> I was reading some early tutorials on it.
>
> My questions are:
>
> (i) Suppose I write
> <script type="text/javascript">
> x="My Name"
> document.write("<h1>x</h1>);
> </script>
>
> would it show the result i.e., the string value of x in header 1?

No, not even if you fix the syntax error (missing trailing quote).

> If not, how can I display the font values to my declared variables?

Do you mean the string value? Like this:-

document.write("<h1>" + x + "<\/h1>");

>
> Is there any good URL to practice/learn on this topic?

What topic?

>
> (ii) Can I combine CSS with JScript?

Javascript. JScript is the name of Microsoft's Javascript
implementation. What do you mean by combine CSS?

> If anyone can give me one/two basic examples, a good URL to learn on
> my own is obviously better.

Examples of what?

>
> (iii) Though Java and Javascript are hugely different but do they have
> any similarity in syntax?

You got it right that time. :) And there are only superficial
similarities.
From: Stevo on
joy99 wrote:
> (i) Suppose I write
> <script type="text/javascript">
> x="My Name"
> document.write("<h1>x</h1>);
> </script>
>
> would it show the result i.e., the string value of x in header 1?
> If not, how can I display the font values to my declared variables?

Why ask the question? It's easier to try it than to find this group and
ask. Two minutes in notepad (or the equivalent simple text editor in
your favorite OS) and drag/drop it onto your favorite browser. If you
drop it onto Firefox, the error console will quickly show you the
trailing quote is missing after </h1>. It's nothing unique to JavaScript
that the code you've written would not use the x variable though. It's
just a letter in a string. You need to break out of the string, access x
and then resume the string:

document.write("<h1>" + x + "</h1>");

You said you were reading some tutorials already? Did you stop at page 4
? This is pretty early-in-the-tutorials kind of stuff.
From: David Mark on
Stevo wrote:
> joy99 wrote:
>> (i) Suppose I write
>> <script type="text/javascript">
>> x="My Name"
>> document.write("<h1>x</h1>);
>> </script>
>>
>> would it show the result i.e., the string value of x in header 1?
>> If not, how can I display the font values to my declared variables?
>
> Why ask the question? It's easier to try it than to find this group and
> ask. Two minutes in notepad (or the equivalent simple text editor in
> your favorite OS) and drag/drop it onto your favorite browser. If you
> drop it onto Firefox, the error console will quickly show you the
> trailing quote is missing after </h1>. It's nothing unique to JavaScript
> that the code you've written would not use the x variable though. It's
> just a letter in a string. You need to break out of the string, access x
> and then resume the string:
>
> document.write("<h1>" + x + "</h1>");

But if it is inline script, you need to escape the slash so the second
string value isn't mistaken for a closing H1 tag.

document.write("<h1>" + x + "<\/h1>");
From: joy99 on
On Feb 21, 2:49 am, David Mark <dmark.cins...(a)gmail.com> wrote:
> Stevo wrote:
> > joy99 wrote:
> >> (i) Suppose I write
> >> <script type="text/javascript">
> >> x="My Name"
> >> document.write("<h1>x</h1>);
> >> </script>
>
> >> would it show the result i.e., the string value of x in header 1?
> >> If not, how can I display the font values to my declared variables?
>
> > Why ask the question? It's easier to try it than to find this group and
> > ask. Two minutes in notepad (or the equivalent simple text editor in
> > your favorite OS) and drag/drop it onto your favorite browser. If you
> > drop it onto Firefox, the error console will quickly show you the
> > trailing quote is missing after </h1>. It's nothing unique to JavaScript
> > that the code you've written would not use the x variable though. It's
> > just a letter in a string. You need to break out of the string, access x
> > and then resume the string:
>
> > document.write("<h1>" + x + "</h1>");
>
> But if it is inline script, you need to escape the slash so the second
> string value isn't mistaken for a closing H1 tag.
>
> document.write("<h1>" + x + "<\/h1>");- Hide quoted text -
>
> - Show quoted text -

Thanx for the answer and sorry for missing the " in the end.
May I put one question back-
How to combine CSS and Javascript? Does anyone know any good tutorial/
url for that?
Regs,
Subhabrata.