?
Solved

Javascript Not Happening

Posted on 2015-01-29
13
Medium Priority
?
115 Views
Last Modified: 2015-01-29
This code isn't working on the last one "rc"  I think it has to do with the hash=='#rc'.
<script type="text/javascript">
/* <![CDATA[ */
if(document.location.hash=='#ord')showhidesection('om');
else if(document.location.hash=='#list')showhidesection('gr');
else if(document.location.hash=='#add')showhidesection('am');
else if(document.location.hash=='#acct')showhidesection('ad');
else if(document.location.hash=='#rc')showhidesection('rc');
/* ]]> */</script>

Open in new window


<?PHP              
              // Your Records
?>			  <tr> 
                <td class="cobhl cobhdr" align="center" height="34" onclick="showhidesection('rc')"><a href="#"><strong><?php print $GLOBALS['xxYourRec']?></strong></a><a href="#" onclick="return false"><img id="sectimageom" src="images/arrow-down.png" style="float:right;margin-right:15px" /></a></td>
			  </tr>
			  <tr class="omformrow" style="display:none"> 
                <td class="cobll" height="34" align="center">
				  <table class="cobtbl" width="100%" border="0" cellspacing="1" cellpadding="3">
<?php		$hastracknum=FALSE;
			$sSQL = "SELECT ordID FROM orders WHERE ordClientID=" . $_SESSION['clientID'] . " AND ordTrackNum<>''";
			$result=ect_query($sSQL) or ect_error();
			if(ect_num_rows($result)>0) $hastracknum=TRUE;
			ect_free_result($result); ?>
					<tr><td class="cobhl"><?php print $GLOBALS['xxOrdId']?></td>
					<td class="cobhl"><?php print $GLOBALS['xxDate']?></td>
					<td class="cobhl"><?php print $GLOBALS['xxStatus']?></td>
<?php		if($hastracknum) print '<td class="cobhl">' . $GLOBALS['xxTraNum'] . '</td>'; ?>
					<td class="cobhl"><?php print $GLOBALS['xxGndTot']?></td>
					<td class="cobhl"><?php print $GLOBALS['xxCODets']?></td></tr>
                    <!--------------------------------------------------------------------------------------->			
<?php
			$sSQL = "SELECT clID,clUserName,clActions,clLoginLevel,clPercentDiscount,clEmail,loyaltyPoints FROM customerlogin WHERE clID=" . $_SESSION['clientID'];
			$result=ect_query($sSQL) or ect_error();
			if(ect_num_rows($result)>0){
				while($rs=ect_fetch_assoc($result)){
					print '<tr><td class="cobll">' . $rs['ordID'] . '</td>';
					print '<td class="cobll">' . date($dateformatstr, strtotime($rs['ordDate'])) . '</td>';
					print '<td class="cobll">' . $rs[getlangid("statPublic",64)] . '</td>';
					if($hastracknum) print '<td class="cobll">' . ($rs['ordTrackNum']!=''?$rs['ordTrackNum']:'&nbsp;') . '</td>';
					print '<td class="cobll">' . FormatEuroCurrency(($rs['ordTotal']+$rs['ordStateTax']+$rs['ordCountryTax']+$rs['ordShipping']+$rs['ordHSTTax']+$rs['ordHandling'])-$rs['ordDiscount']) . '</td>';
					print '<td class="cobll"><a class="ectlink" href="javascript:vieworder(' . $rs['ordID'] . ')">' . $GLOBALS['xxClkHere'] . '</a></td></tr>';
				}
			}else{
				print '<tr><td class="cobll" colspan="5" height="34" align="center">' . $GLOBALS['xxNoOrd'] . '</td></tr>';
			}
			ect_free_result($result);
?>
				  </table>

Open in new window

0
Comment
Question by:DS928
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 40579006
Where are you setting the anchor part in this code?  I don't see any anchor part being set for 'rc'. Maybe that's why it's not working.
0
 

Author Comment

by:DS928
ID: 40579013
Not sure what you mean by anchor?  Is this it?
<script type="text/javascript">
/* <![CDATA[ */
var currstate=[];
currstate['ad']='none';
currstate['am']='none';
currstate['gr']='none';
currstate['om']='none';
currstate['rc']='none';
function showhidesection(sect){
	var elem=document.getElementsByTagName('tr');
	currstate[sect]=currstate[sect]=='none'?'':'none';
	for(var i=0; i<elem.length; i++){
		var classes=elem[i].className;
		if(classes.indexOf(sect+'formrow')!=-1) elem[i].style.display=currstate[sect];
	}
	document.getElementById('sectimage'+sect).src=currstate[sect]=='none'?'images/arrow-down.png':'images/arrow-up.png';
	return false;
}
/* ]]> */</script>

Open in new window

0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 40579018
Nope.  You are using this javascript code:

document.location.hash=='#rc'

Open in new window


location.hash is used to point to an anchor in an HTML page...but I'm guessing that is not your goal.

What is your goal with your code?
0
WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

 

Author Comment

by:DS928
ID: 40579041
It's being used to drop-down a menu header.  Go to www.mediascrubber.com  click on MyAccount
Enter rh@aol.com for the user name and RH1234 for the password.  A page with blue bars appears.  Order and Records seem to be tangled up.  When you click on Orders both open.  when you click on Records nothing opens.
0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 40579044
This line is coming back null...it's missing the id you need...

document.getElementById('sectimage'+sect).src=currstate[sect]=='none'?'images/arrow-down.png':'images/arrow-up.png';

Open in new window

0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 40579048
Can you paste the code you have for the order management section or all of the other sections?
0
 

Author Comment

by:DS928
ID: 40579056
Better yet here is the file.
incclientlogin.php
0
 
LVL 13

Accepted Solution

by:
Andrew Derse earned 2000 total points
ID: 40579058
Ok, I think I found it.

Line item 921, the image id is the same as the om...change the image id to: sectimagerc and see if that works.

You have two id's for the same image...changing it might do the trick.
0
 

Author Comment

by:DS928
ID: 40579065
Didn't work
0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 40579073
Did that get posted to the site?  So, I can verify the changes and see the new error?
0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 40579085
You must be working on it now as it's displaying a little differently than before.  Well, I'm off to bed for today so tomorrow if it's not resolved, let me know and I'll peak at it more.  It most certainly seems like an id issue within the js.  Something isn't being passed correctly.
0
 

Author Comment

by:DS928
ID: 40579089
I changed in two places.

<img id="sectimagegr" src="images/arrow-down.png" style="float:right;margin-right:15px" /></a></td>
			  </tr>
			  <tr class="grformrow" style="display:none"> 

Open in new window

That worked.
0
 

Author Closing Comment

by:DS928
ID: 40579090
Sleep tight!  Thank you.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question