|
|
JavaScript: Settings values for generated objects and book recomendations
|
|
|
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
I've had this particular problem before and I never did solve it and I need to get this working now... Essentially I am dynamically generating a table.. which works well enough. My problem is that I'm not sure exactly how to set all the values I want. Are there any good references available? The one I'm using now is DevGuru's JavaScript index. It's good but seems to be missing certain things. Particularly I want to be able to set the valign, onmouseover, and onmouseup properties of a table row. I've tried just "mytablerow.valign" and mouseover, mouseup etc... but it doesn't seem to work.
Secondly... I'm experimenting more and more with javascript and was wondering if anyone could suggest a good book that explains the DOM/JavaScript and then goes into more advanced methods... JavaScript is my weak spot and I'm looking to become more familiar with it.
Thanks for any help
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Feb 2004
Location: Manhattan
Status:
Offline
|
|
If you want to set the same valign value for all td tags, you need to create a td object:
{
var cells = window.document.getElementsByTagName('td');
for(var i = 0; i < cells.length; i++)
//this iterates through all the td tags
{
//then set the value here
document.cells(i).valign="value";
}
I haven't tested that code, but it's a start. I'm not sure if that works with HTML properties, or if you need to use the CSS equivalent.
If you want to set different valign values for each td, then it gets more complex than that. You have to add another if statement, or perhaps even use switch case statement if there's lots of different ones.
|
I saw a woman with a sweatshirt that said "Guess", so I said, "Implants?"
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
Being a standards junkie, I'd do setAttribute("valign",whatever); rather than Dunsels version.... However, that can sometime's cause problems depending on your doctype (and browser implementation....)
Anyhoo, for your mouseover thing, you could do something like:
Code:
function someFunction(e) {
e = (e.target)? e.target : event.srcElement;
//stuff involving the element that has been mouseovered, identified by e...
}
(document.addEventListener) ? document.addEventListener("mouseover",someFunction, false) : document.attachEvent("onmouseover", someFunction);
//although you'd likely want to attach the event to an element rather than the document...
to go for a cross platform way...
Anyhoo - the same thing applies for the mouseup event...
Oh, go to http://devedge.netscape.com/library/...1.5/reference/ for a reference on javascript.. It kinda depends on what your experience with programming is as to how helpful it is... Sursprisingly JavaScript is the language I first started with, and then I moved onto C etc (backward, I know) - but that reference is great for me now.. If i dig up my old bookmarks from when I was learning JavaScript, I'll let you know. They might be helpful....
(edited because I was drunk when I posted this and sounded like an arse...)
(
Last edited by Black Book; Apr 26, 2004 at 04:50 AM.
)
|
Just who are Britain? What do they? Who is them? And why?
Formerly Black Book
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|