Webmaster Forum

Ezilon Directory   High Bandwidth Dedicated Servers   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 05-05-2008, 06:32 AM   #1 (permalink)
Junior Member
 
Join Date: 04-22-08
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
js function issue

I'm trying to write a js function to complete two tasks with one event.

basically an onclick that checks to see if an img src is a specific pic then run actions based on that..below is my code which should give you an understanding of what i'm trying to accomplish... my problem i'm having is that the function will work the first time.. but not on the second click.

I would appreciate any advice somone can give.. ty

HTML
Code:
<div id='Alinkz'> <div id='TCbox2'></div> <div id='AlinkzDiv' style='height:15px;overflow:hidden;' onclick='switchArrows1();'> EDIT MENU LINKS&nbsp;<img id='collapser1' src='imgs/arrowsdown.png' /><hr width='400px' /> <?php require('forms/Lkzform.php');?> </div> <div id='BCbox2'></div> </div>
JS
Code:
function switchArrows1() { if(document.getElementById("collapser1").src='imgs/arrowsdown.png') { document.getElementById("collapser1").src='imgs/arrowsup.png'; document.getElementById("AlinkzDiv").style.height="100%"; } else if(document.getElementById("collapser1").src='imgs/arrowsup.png') { document.getElementById("collapser1").src='imgs/arrowsdown.png'; document.getElementById("AlinkzDiv").style.height="15px"; } else { document.getElementById("collapser1").src='imgs/arrowsdown.png'; } }
ag3nt42 is online now  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 05-05-2008, 07:25 AM   #2 (permalink)
Junior Member
 
Join Date: 04-22-08
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
anyone?
ag3nt42 is online now  
Add Post to del.icio.us
Reply With Quote
Old 05-05-2008, 02:10 PM   #3 (permalink)
Contributing Member
 
Join Date: 07-24-06
Posts: 563
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the rough
Code:
if(document.getElementById("collapser1").src='imgs/arrowsdown.png') ... else if(document.getElementById("collapser1").src='imgs/arrowsup.png')
I think there should be ==, JS comparison operator (not the assignment).
nasty.web is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-06-2008, 11:58 AM   #4 (permalink)
Junior Member
 
Join Date: 04-22-08
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
tryed that doesn't seem to be working...

Code:
function switchIT() { if(document.getElementById('collapser').src=='arrowsdown.png') { document.getElementById('AlinkzDiv').style.height="100%"; document.getElementById('collapser').src="imgs/arrowsup.png"; } else if (document.getElementById('collapser').src=='arrowsup.png') { document.getElementById('AlinkzDiv').style.height="15px"; document.getElementById('collapser').src="imgs/arrowsdown.png"; } else { alert('ERROR!!!! DUDE!!!'); } }
comes back everytime error
ag3nt42 is online now  
Add Post to del.icio.us
Reply With Quote
Old 05-06-2008, 12:00 PM   #5 (permalink)
Contributing Member
 
Join Date: 07-24-06
Posts: 563
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the roughnasty.web is a jewel in the rough
change the last alert into
Code:
alert('ERROR!!!! DUDE!!!'+document.getElementById('collapser').src);
and you'll see what the real collapser image path is.
nasty.web is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-06-2008, 12:06 PM   #6 (permalink)
Junior Member
 
Join Date: 04-22-08
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
gives me the full path to the image...do i have to use the full path?
ag3nt42 is online now  
Add Post to del.icio.us
Reply With Quote
Old 05-06-2008, 12:08 PM   #7 (permalink)
Junior Member
 
Join Date: 04-22-08
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
wow talk about over killl its working if i use the fully path

thanx for the help nasty.. spose i'll setup a varible now for that long path name lol...

you think that js would be smart enough to just snatch the name of the file instead of treating it like a fully string.

works now tho..

Last edited by ag3nt42 : 05-06-2008 at 12:11 PM. Reason: more to say
ag3nt42 is online now  
Add Post to del.icio.us
Reply With Quote
Old 05-07-2008, 06:15 AM   #8 (permalink)
Contributing Member
 
Join Date: 09-03-07
Location: England
Posts: 358
iTrader: 0 / 0%
Latest Blog:
None

Boogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebodyBoogle is liked by somebody
well no, if you think about it, the JS is only active one the page loads (or your HTTP state is 4)

so actually the Jscript is seiving through your full code and since the browserss renders your <img src="img1.jpg" /> to <img src="http://www.mysite.com/images/img1.jpg" /> then the Jscript sees "src='http://www.mysite.com/images/img1.jpg'" and not "src=img1.jpg" />

Make any sense?

Boog's
__________________
Price is what you pay... Value is what you get.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Old 05-12-2008, 09:45 AM   #9 (permalink)
Junior Member
 
Join Date: 04-22-08
Posts: 21
iTrader: 0 / 0%
Latest Blog:
None

ag3nt42 is liked by many
yea it makes sense but you'd think that the JS writers would allow it to skip past the file path and recognize the file itself ya kno?

to make things simple for myself i ended up just throwing a variable in there that held the path information.
ag3nt42 is online now  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
WOMD - Issue or Non-issue John Scott Politics 1 08-02-2007 08:30 AM
Does wordpress have an email function? DarkNinja Blogging Forum 1 03-24-2006 09:07 AM
need help: trouble with mail function.... cuongdm Coding Forum 3 12-25-2005 10:49 PM
function SymError GoldDust Coding Forum 3 02-25-2004 07:19 AM
CSS Function Reference Leader of Men Coding Forum 4 02-03-2004 01:11 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 04:59 AM.
© Copyright 2008 V7 Inc


Search Engine Optimization by vBSEO 3.1.0 ©2007, Crawlability, Inc.