LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-02-2005, 02:30 PM   #1
djgerbavore
Member
 
Registered: Jun 2004
Location: PA
Distribution: Fedora (latest git kernel)
Posts: 458

Rep: Reputation: 30
javaScript - DOM,


hello,
i have this webpage that is semi big, and i'm writing some javascript to fix it up and make it more streamline. however, i don't know the path of some of my html objects.

for example

Code:
<input type = "radio" value="0" name="myradio">Radio

<select name = "sel" id ="sel" >
<option name="1">Option 1 </option>
<option name="2"> Option 2</option>
</select>
i want to add:

Code:
<input type = "radio" value="0" name="myradio" 
onclick = javafunct(document.myformName.sel)>Radio
but i get errors, saying that "document.myformName.sel is null or not an object.


however when i do:
Code:
<select name = "sel" id ="sel" onchange(this)>
<option name="1">Option 1 </option>
<option name="2"> Option 2</option>
</select>
it works fine,
so my question is, can print out the DOM path of "this"? (which my select menu)

i think that the select object is nested somewhere, but its hard to tell, and i didn't write the webpage, i'm just fixing it up for someone...

thanks,

djgerbavor3

Last edited by djgerbavore; 03-02-2005 at 02:32 PM.
 
Old 03-03-2005, 04:11 AM   #2
coolman0stress
Member
 
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
this is the *current* object, you can use it to manipulate things around it (if I'm understanding the question correctly). If you want to get to some specific element of your page, then try using document.getElementById to retrieve the object with a specific id (assuming you gave it an id). getElementsByTagName and getElementsByName are also helpfull.

Btw, always make sure to quote your JavaScript functions. It should be:

Code:
onclick='myfunc("param1","param2");'
 
Old 03-03-2005, 04:44 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Were I you, I would use the excellent Mozilla DOM Inspector (see the Tools menu). It even has a Javascript view!

Yves.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Login in a NT-Dom over PAM/Winbindd skober19 Linux - Networking 1 11-09-2005 11:55 PM
DOM inspector in konqueror upset Programming 2 03-08-2005 04:44 PM
lookin for a javascript DOM guru... pld Programming 1 02-17-2005 05:14 PM
php with DOM suport bm1 Linux - Software 0 05-17-2004 07:32 AM
XML php dom amirspl Programming 2 09-20-2003 06:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration