Solved

Javascript Not Happening

Posted on 2015-01-29
13
110 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
  • 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

831 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