Re: I don't get javascript. How do you use it?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



z-index is the CSS property that controls layering of elements in a web
page. To use it within the realm of CSS, case doesn't matter (since CSS is
also not case-sensitive, like HTML) and it is used as: z-index (with the
hyphen).

When you want to access a CSS property from within a language like
JavaScript, then you must follow the case sensitivity of the language you
are in. JavaScript is case-sensitive (unlike CSS and HTML), so even if you
wish to affect some CSS, you would now have to use the correct case. Also,
in JavaScript (or more accurately, the Browser's Object Model or BOM) that
is accessed via JavaScript, the object properties that affect CSS don't
always match their CSS counterparts. For exapmle:

[Straight CSS inside a web page's HTML]

<!-- case does not matter in the following -->
<P ID="theText" STYLE="z-index:1">some text</P>

[JavaScript embedded within HTML]

<SCRIPT TYPE="text/JavaScript">
// case does matter in here because this area is JavaScript
theText.style.zIndex = 2;
</SCRIPT>

In short, when writing any kind of code, you must write it according to the
language that you are writing at the time.

If you really want to get a grasp of what your question encompasses, you'll
need to research the following:

-HTML
-CSS
-JavaScript
-The Document Object Model (standard OO API to a web document)
-The Browser Object Model (sometimes people confuse this with the Document
Object Model) (vendor specific OO API to browser and document)

-Scott

"Tony Girgenti" <tony(nospam)@lakesideos.com> wrote in message
news:uVcnf06bHHA.264@xxxxxxxxxxxxxxxxxxxxxxx
Hello Goran.

You obviously know a lot about javascript. How does a person figure
whether to use "z-index" or "zindex" or "zIndex" or "ZINDEX" or whatever.

Is that kind of stuff documented somewhere?

Thanks,
Tony

--
Any help would be gratefully appreciated.

Thanks,
Tony

"Göran Andersson" <guffa@xxxxxxxxx> wrote in message
news:%23q7SiYybHHA.4872@xxxxxxxxxxxxxxxxxxxxxxx
Tony Girgenti wrote:
Thanks to everyone for their replies.

I finally figured it out. There were several issues. One problem was
that i was using "onClick" with a capital "C" in the HTML button.
Another issue was i didn't need a ";" at the end of the onclick
statement, but i did need the "()".

I know that i probably confused everybody by showing different versions
of the code that i had, and i apologize for that. Both of the buttons
work now using the following function:
function ShowMsg()
{
alert(Calendar1.innerText);
myElement = document.getElementById("Calendar1");
alert(myElement.style.position);
}

With the HTML button i used "onclick="ShowMsg()" and with the ASP button
i used "onClientClick="ShowMsg()" . The Calendar1 displays then the
position property displays.

However, i still can't get the "z-index" or "zindex" to display. For
the "z-index" it gives an error on line 14, character 9 and for
"zindex", It just displays "undefined" in the alert. Line 14, character
9 is the "}" in my function.

That's because it's zIndex, not zindex. Look at the code in my previous
code.

Not that i would really ever want to display the z-index of any element
in a real situation, i'm just curious as to why it won't display.

I'm on my way now to practicing and learning more about javascript and i
really appreciate everybody's help in figuring this stuff out.

Thanks,
Tony

"Scott M." <s-mar@xxxxxxxxxxxxx> wrote in message
news:u$cwZ7lbHHA.2076@xxxxxxxxxxxxxxxxxxxxxxx
Or, in your page_load event, programmably add the client-side event
handler:

Button1.attributes.add("onclick","ShowCal()")

By the way, remember to include the parenthesis in your JavaScript
function call, as they are part of the function name (see above). Now,
as long as you do have a client-side JavaScript function called
ShowCal(), and it is coded correctly, clicking your button will invoke
the function.

-Scott

"Göran Andersson" <guffa@xxxxxxxxx> wrote in message
news:OWuzw7jbHHA.4656@xxxxxxxxxxxxxxxxxxxxxxx
Tony Girgenti wrote:
Hello.

I just finished reading two articles about javascript here:
http://msdn2.microsoft.com/en-us/library/bb332123(VS.80).aspx

I tried some javascript testing in VS2005, SP1, VB , .NET 2.0,
ASP.NET 2.0 on WIN XP Pro, SP2.

It's real simple. I put a button on a page and coded the onClick in
it like this:
<asp:Button ID="Button1" runat="server" Style="z-index: 103; left:
528px; position: absolute; top: 392px" Text="Button"
OnClick="ShowCal" />

Here is the function:
<script type="text/javascript" language="javascript">
function ShowCal() {
var x = Button1.Style.z - index;
alert(x);
}
</script>

It won't let me run the program saying "'ShowCal' is not a member of
'ASP.default_aspx'"

If javascript is so popular, why can't i use it?

Any help would be gratefully appreciated.

Thanks,
Tony

As Mark said, the OnClick event of a server control is a server event.

Use the OnClientClick property to create a client side onclick event.
Or use an html element instead:

<input type="button" style="position: absolute; z-index: 103; left:
528px; top: 392px;" value="Button" onclick="ShowCal();" />

Notice that the onclick property contains the code to call the
function, not just the function name.

Some browsers expose the elements with an id as properties in the
document, but you should use the getElementById to access them to
write code that works in all (modern) browsers. Javascript is case
sensetive, so you have to write all names using the correct case.

<script type="text/javascript">

function ShowCal() {
var x = document.getElementById('Button1').style.zIndex;
alert(x);
}

</script>

--
Göran Andersson
_____
http://www.guffa.com





--
Göran Andersson
_____
http://www.guffa.com




.



Relevant Pages

  • Re: search results question..
    ... I believe that Google will often use text from the page, ... It seems that javascript is necessary to use your site, ... do you mean JavaScript or CSS? ... meta-description tags if CSS is disabled?? ...
    (alt.internet.search-engines)
  • Re: New to programming
    ... Absolutely --ALL-- web development requires the use of JavaScript and it just so happens the punctuation for C# and JavaScript are exactly the same so you get to learn two languages for the price of one so to speak. ... You should start with HTML and CSS and just get a grip on how to build a static page noting the most critical part is CSS as the many browsers all parse CSS differently in many ways so its become a nightmare in a manner of speaking. ... When you are ready to learn C# I recommend using a real textbook from Deitel and Deitel having been a classrom instructor myself as there are many good books of course but none are structured and what you are actually learning is OOP and learning Object Oriented Programming is quite complex and ...
    (microsoft.public.dotnet.general)
  • Re: search results question..
    ... I believe that Google will often use text from the page, ... It seems that javascript is necessary to use your site, ... do you mean JavaScript or CSS? ... That disables CSS. ...
    (alt.internet.search-engines)
  • Re: No TABLES in html. No hacks in CSS. Any layout possible, crossbrowser. Try it.
    ... Disable JavaScript, like ~10% of your visitors, and look at your ... HTML and CSS can do much more than you seem to realize. ... transitioning from? ...
    (comp.infosystems.www.authoring.html)
  • Re: Stylesheet format lost after adding onClick
    ... that onClick was the same as. ... Can you recommend how I can use CSS to define the ... since a visible hyperlink can receive the ... Prototype.js was written by people who don't know javascript for people ...
    (comp.lang.javascript)