User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 427,415 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,518 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1406 | Replies: 4 | Solved
Join Date: Feb 2008
Posts: 7
Reputation: adrumsolo4u is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
adrumsolo4u adrumsolo4u is offline Offline
Newbie Poster

onclick toggle

  #1  
Feb 29th, 2008
i have been trying to find a way to do it, but i can't seem to think of one. i need to do this:
  1. var animElements = document.getElementById("resizercontainer").getElementsByTagName("p")
  2. for(var i=0; i<animElements.length; i++) {
  3. animElements[i].onmouseover = widthChange;
  4. animElements[i].onmouseout = widthRestore;
  5. }
  6. function widthChange() {
  7. if (!this.currentWidth) this.currentWidth = 150;
  8. doWidthChangeMem(this,this.currentWidth,170,10,10,0.333);
  9. }
  10. function widthRestore() {
  11. if (!this.currentWidth) return;
  12. doWidthChangeMem(this,this.currentWidth,150,10,10,0.5);
  13. }

but i want to use .onclick instead of .onmouseover and .onmouseout
i have come up with this:

  1. var animElements = document.getElementById("both").getElementsByTagName("p");
  2. for(var i=0; i<animElements.length; i++) {
  3. if (currentwidth = 150){animElements[i].onclick = sizeChange;}
  4. else {animElements[i].onclick = sizeRestore;}
  5. }
  6. function sizeChange() {
  7. if (!this.currentWidth) this.currentWidth = 150;//if no mem is set, set it first;
  8. doWidthChangeMem(this,this.currentWidth,170,10,10,0.333);
  9. }
  10. function sizeRestore() {
  11. doWidthChangeMem(this,this.currentWidth,150,10,10,0.5);
  12. }

but i still have not found a way for it to detect if it has been clicked before.
any help would be apreciated
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC