/    Sign up×
Community /Pin to ProfileBookmark

Capture Node Id

I have an expandable menu script.

When the menuitem is clicked it expands using this part
/**
actuator.onclick = function() {
var display = menu.style.display;

var statusBox = “sessionCrew”;
statusBox =+ “0”;

this.parentNode.style.backgroundImage =
(display == “block”) ? “url()” : “url()”;
menu.style.display = (display == “block”) ? “none” : “block”;

window.document.scheduleDetail.elements[statusBox].value = display
**/

I am trying to capture the ID of the item being clicked so I can parse the name to write the current display attribute to a hidden text box on my form. The goal is to remember how the menus were expanded and compressed when you return to the page.

By using the hidden boxes when the user leaves the page, I capture the hidden box info to session variables. Then when they return to the page the script reads the session variables and sets the menu open or closed base on how it was left.

Probably more info than needed, but hey maybe there is a better way. I just can’t find a good reference to find out all the properties of parentNode (such as parentNode.style etc)

Thanks!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@BillyRayAug 12.2004 — I just can't find a good reference to find out all the properties of parentNode[/quote]

That will depend entirely on what sort of element parentNode points to.

Dan
Copy linkTweet thisAlerts:
@ianjkingauthorAug 12.2004 — document.getElementById(actuatorId).getAttribute('id');

This accomplished my goal and gives me the id of the item which was clicked. The variable(actuatorId) was defined earlier in my script during the intialization of each element.

Can't tell you why it works (still a newbie) but using an alert() I have it pop up the id each time I click on an element and it is giving me the correct name.

Ian
×

Success!

Help @ianjking spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...