110mb.com Forum
News: All accounts on B15 registered before 28 Aug are gone. Please register it again and reupload your files. Will restore lost data on your account by +-6th Sept.
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 06, 2008, 02:09:24 AM


Login with username, password and session length


Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: only one javscript works  (Read 215 times)
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« on: July 25, 2008, 07:01:54 AM »

I have two script tags:
Code:
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="tables.js"></script>

but the problem is that only tables.js works, please help.
thanks.
Logged

Busman
Genetically Modified
Advanced Authority Member
*****
Offline Offline

Posts: 1022



« Reply #1 on: July 25, 2008, 07:06:47 AM »

A link would be useful.
Logged
bind
just a man
Authority Member
****
Offline Offline

Posts: 592


« Reply #2 on: July 25, 2008, 07:46:42 AM »

look for conflicting (identical) variable or function names in the two javascripts.

if dynamically altering or administrating forms or innerhtml, they need to be named and addressed separately.

post your page source code and the source code to the javascripts and any includes if you cant figure it out.
Logged

"... if you give a man a fish, he eats today ... if you teach a man to fish, he eats for the rest of his life ..."

That means I am not here to do your work for you, but to assist you in learning how to code what you need. If you want someone to code for you, hire someone to do it or use an out of the box app. All unsolicited pm's are deleted without reading.
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #3 on: July 25, 2008, 08:10:16 AM »

it's not really online, it's a work in progress.
I can't post it but I just uploaded it: http://shedokan.110mb.com/bux/admin/index.php?p=2
Logged

bind
just a man
Authority Member
****
Offline Offline

Posts: 592


« Reply #4 on: July 25, 2008, 08:19:34 AM »

I can't post it

yes you can.

between bbCode CODE tags like this

Code:
//
//  source code here
//
« Last Edit: July 25, 2008, 08:21:38 AM by bind » Logged

"... if you give a man a fish, he eats today ... if you teach a man to fish, he eats for the rest of his life ..."

That means I am not here to do your work for you, but to assist you in learning how to code what you need. If you want someone to code for you, hire someone to do it or use an out of the box app. All unsolicited pm's are deleted without reading.
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #5 on: July 25, 2008, 08:26:34 AM »

I know but it's easier to show than explain  wink, and if you didn't notice I uploaded it.
Logged

bind
just a man
Authority Member
****
Offline Offline

Posts: 592


« Reply #6 on: July 25, 2008, 09:00:42 AM »

I have no doubt that providing as little information as possible and no code is easier for you.

good luck with it.
Logged

"... if you give a man a fish, he eats today ... if you teach a man to fish, he eats for the rest of his life ..."

That means I am not here to do your work for you, but to assist you in learning how to code what you need. If you want someone to code for you, hire someone to do it or use an out of the box app. All unsolicited pm's are deleted without reading.
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #7 on: July 25, 2008, 09:07:29 AM »

can't you just go to the page and see the source code?!
it's easier for you if I'll post it here but maybe there are more files, so I should post 10 files source code here? instead of making it easier for you and me?
Logged

confuser
Likes to baffle people
Super Authority member
******
Offline Offline

Posts: 1905


The Forum's Angel


WWW
« Reply #8 on: July 25, 2008, 07:51:31 PM »

well from the HTML on that site i couldnt see the <script> for menu.js  huh
This may sound silly but everyone does it sometimes (including me lol), is that file in the location specified?
Logged


D3xt3r
"Give me the place to stand, and I shall move the Earth"
Global Moderator
Loyal 110MB Member
*****
Online Online

Posts: 2797


/root/D/3/X/T/3/R


WWW
« Reply #9 on: July 25, 2008, 09:48:38 PM »

can't you just go to the page and see the source code?!
it's easier for you if I'll post it here but maybe there are more files, so I should post 10 files source code here? instead of making it easier for you and me?

Provide the source code here, or please wait for somebody who is willing to do all the work.
Logged




I am not taking project requests at the moment...
I have my own projects and work, please do not request, thank you...
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #10 on: July 25, 2008, 10:14:01 PM »

I just renamed the script names, the real names are: "sdmenu/sdmenu.js" and "tablecloth/tablecloth.js".
if you want here's the source code, but it will be harder for you to understand.
index.php:
Code:
<!--Force IE6 into quirks mode with this comment tag-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PTC Earner - Admin - Earning more from PTC sites</title>
<link href="tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="sdmenu/sdmenu.css" />
<script type="text/javascript" src="sdmenu/sdmenu.js">
/***********************************************
* Slashdot Menu script- By DimX
* Submitted to Dynamic Drive DHTML code library: http://www.dynamicdrive.com
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>

<script type="text/javascript">
// <![CDATA[
var nav;
window.onload = function() {
nav = new SDMenu('nav');
nav.init();
nav.remember = false;               // Store menu states (expanded or collapsed) in cookie and restore later
nav.oneSmOnly = true;             // One expanded submenu at a time
};
// ]]>
</script>
<script type="text/javascript" src="tablecloth/tablecloth.js"></script>
</head>
<body>
<div id="framecontent">
<div class="innertube">
<div style="float: left;" id="nav" class="sdmenu">
<div class='' style=''>
<span>PTC sites</span>

<a href="?p=1">Edit Sites</a>
<a href="?p=2">Add Sites</a>
<a href="?p=3">Suggested Sites</a>
</div>
<div>
<span>Pyments</span>
<a href="?p=4">Payments Requests</a>

</div>
<div>
<span>Users</span>
<a href="?p=5">Edit Users</a>
<a href="?p=6">Search Users</a>
<a href="?p=7">List Emails</a>
<a href="?p=8">Mass Email</a>

</div>
<div>
<span>Contact</span>
<a href="?p=9">Messages</a>
</div>
</div>
</div>
</div>

<div id="maincontent">
<div class="innertube">

<b>Edit Sites</b>

<table cellspacing="0" cellpadding="0">
<tr>
<th>Id</th>
<th>Name</th>
<th>Url</th>

<th>Raito</th>
<th>Payed</th>
<th>Use</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>

<tr>

<td>1</td>
<td>Domain</td>
<td><a href="http://www.domain.com" target="_blank">http://www.domain.com</a></td>
<td>0.01</td>
<td>0</td>
<td>0</td>

<td>
<form method="post" action="index.php?p=1&id=1&do=edit"><input type="submit" value="Edit"></form>
</td>
<td>
<form method="post" action="index.php?p=1&id=1&do=delete"><input onclick="return confirm('Really delete this site?');" type="submit" value="Delete"></form>
</td>
</tr>

<tr>

<td></td>
<td></td>
<td><a href="http://" target="_blank">http://</a></td>
<td>0.01</td>
<td></td>
<td></td>
<td>
<form method="post" action="index.php?p=1&id=&do=edit"><input type="submit" value="Edit"></form>

</td>
<td>
<form method="post" action="index.php?p=1&id=&do=delete"><input onclick="return confirm('Really delete this site?');" type="submit" value="Delete"></form>
</td>
</tr>

<tr>
<td></td>
<td></td>

<td><a href="http://" target="_blank">http://</a></td>
<td>0.01</td>
<td></td>
<td></td>
<td>
<form method="post" action="index.php?p=1&id=&do=edit"><input type="submit" value="Edit"></form>
</td>
<td>

<form method="post" action="index.php?p=1&id=&do=delete"><input onclick="return confirm('Really delete this site?');" type="submit" value="Delete"></form>
</td>
</tr>

<tr>
<td></td>
<td>NeoBux</td>
<td><a href="http://www.neobux.com" target="_blank">http://www.neobux.com</a></td>

<td>0.0</td>
<td></td>
<td></td>
<td>
<form method="post" action="index.php?p=1&id=&do=edit"><input type="submit" value="Edit"></form>
</td>
<td>
<form method="post" action="index.php?p=1&id=&do=delete"><input onclick="return confirm('Really delete this site?');" type="submit" value="Delete"></form>

</td>
</tr>
</table>
</div>
</div>
</body>
</html>

tablecloth.js:
Code:
/*

Tablecloth
written by Alen Grakalic, provided by Css Globe (cssglobe.com)
please visit http://cssglobe.com/lab/tablecloth/

*/

this.tablecloth = function(){

// CONFIG

// if set to true then mouseover a table cell will highlight entire column (except sibling headings)
var highlightCols = false;

// if set to true then mouseover a table cell will highlight entire row (except sibling headings)
var highlightRows = true;

// if set to true then click on a table sell will select row or column based on config
var selectable = true;

// this function is called when
// add your own code if you want to add action
// function receives object that has been clicked
this.clickAction = function(obj){
//alert(obj.innerHTML);

};



// END CONFIG (do not edit below this line)


var tableover = false;
this.start = function(){
var tables = document.getElementsByTagName("table");
for (var i=0;i<tables.length;i++){
tables[i].onmouseover = function(){tableover = true};
tables[i].onmouseout = function(){tableover = false};
rows(tables[i]);
};
};

this.rows = function(table){
var css = "";
var tr = table.getElementsByTagName("tr");
for (var i=0;i<tr.length;i++){
css = (css == "odd") ? "even" : "odd";
tr[i].className = css;
var arr = new Array();
for(var j=0;j<tr[i].childNodes.length;j++){
if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
};
for (var j=0;j<arr.length;j++){
arr[j].row = i;
arr[j].col = j;
if(arr[j].innerHTML == "&nbsp;" || arr[j].innerHTML == "") arr[j].className += " empty";
arr[j].css = arr[j].className;
arr[j].onmouseover = function(){
over(table,this,this.row,this.col);
};
arr[j].onmouseout = function(){
out(table,this,this.row,this.col);
};
arr[j].onmousedown = function(){
down(table,this,this.row,this.col);
};
arr[j].onmouseup = function(){
up(table,this,this.row,this.col);
};
arr[j].onclick = function(){
click(table,this,this.row,this.col);
};
};
};
};

// appyling mouseover state for objects (th or td)
this.over = function(table,obj,row,col){
if (!highlightCols && !highlightRows) obj.className = obj.css + " over"; 
if(check1(obj,col)){
if(highlightCols) highlightCol(table,obj,col);
if(highlightRows) highlightRow(table,obj,row);
};
};
// appyling mouseout state for objects (th or td)
this.out = function(table,obj,row,col){
if (!highlightCols && !highlightRows) obj.className = obj.css;
unhighlightCol(table,col);
unhighlightRow(table,row);
};
// appyling mousedown state for objects (th or td)
this.down = function(table,obj,row,col){
obj.className = obj.css + " down"; 
};
// appyling mouseup state for objects (th or td)
this.up = function(table,obj,row,col){
obj.className = obj.css + " over"; 
};
// onclick event for objects (th or td)
this.click = function(table,obj,row,col){
if(check1){
if(selectable) {
unselect(table);
if(highlightCols) highlightCol(table,obj,col,true);
if(highlightRows) highlightRow(table,obj,row,true);
document.onclick = unselectAll;
}
};
clickAction(obj);
};

this.highlightCol = function(table,active,col,sel){
var css = (typeof(sel) != "undefined") ? "selected" : "over";
var tr = table.getElementsByTagName("tr");
for (var i=0;i<tr.length;i++){
var arr = new Array();
for(j=0;j<tr[i].childNodes.length;j++){
if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j]);
};
var obj = arr[col];
if (check2(active,obj) && check3(obj)) obj.className = obj.css + " " + css;
};
};
this.unhighlightCol = function(table,col){
var tr = table.getElementsByTagName("tr");
for (var i=0;i<tr.length;i++){
var arr = new Array();
for(j=0;j<tr[i].childNodes.length;j++){
if(tr[i].childNodes[j].nodeType == 1) arr.push(tr[i].childNodes[j])
};
var obj = arr[col];
if(check3(obj)) obj.className = obj.css;
};
};
this.highlightRow = function(table,active,row,sel){
var css = (typeof(sel) != "undefined") ? "selected" : "over";
var tr = table.getElementsByTagName("tr")[row];
for (var i=0;i<tr.childNodes.length;i++){
var obj = tr.childNodes[i];
if (check2(active,obj) && check3(obj)) obj.className = obj.css + " " + css;
};
};
this.unhighlightRow = function(table,row){
var tr = table.getElementsByTagName("tr")[row];
for (var i=0;i<tr.childNodes.length;i++){
var obj = tr.childNodes[i];
if(check3(obj)) obj.className = obj.css;
};
};
this.unselect = function(table){
tr = table.getElementsByTagName("tr")
for (var i=0;i<tr.length;i++){
for (var j=0;j<tr[i].childNodes.length;j++){
var obj = tr[i].childNodes[j];
if(obj.className) obj.className = obj.className.replace("selected","");
};
};
};
this.unselectAll = function(){
if(!tableover){
tables = document.getElementsByTagName("table");
for (var i=0;i<tables.length;i++){
unselect(tables[i])
};
};
};
this.check1 = function(obj,col){
return (!(col == 0 && obj.className.indexOf("empty") != -1));
}
this.check2 = function(active,obj){
return (!(active.tagName == "TH" && obj.tagName == "TH"));
};
this.check3 = function(obj){
return (obj.className) ? (obj.className.indexOf("selected") == -1) : true;
};

start();

};

/* script initiates on page load. */
window.onload = tablecloth;

sdmenu.js:
Code:
function SDMenu(id) {
if (!document.getElementById || !document.getElementsByTagName)
return false;
this.menu = document.getElementById(id);
this.submenus = this.menu.getElementsByTagName("div");
this.remember = true;
this.speed = 3;
this.markCurrent = true;
this.oneSmOnly = false;
}
SDMenu.prototype.init = function() {
var mainInstance = this;
for (var i = 0; i < this.submenus.length; i++)
this.submenus[i].getElementsByTagName("span")[0].onclick = function() {
mainInstance.toggleMenu(this.parentNode);
};
if (this.markCurrent) {
var links = this.menu.getElementsByTagName("a");
for (var i = 0; i < links.length; i++)
if (links[i].href == document.location.href) {
links[i].className = "current";
break;
}
}
if (this.remember) {
var regex = new RegExp("sdmenu_" + encodeURIComponent(this.menu.id) + "=([01]+)");
var match = regex.exec(document.cookie);
if (match) {
var states = match[1].split("");
for (var i = 0; i < states.length; i++)
this.submenus[i].className = (states[i] == 0 ? "collapsed" : "");
}
}
};
SDMenu.prototype.toggleMenu = function(submenu) {
if (submenu.className == "collapsed")
this.expandMenu(submenu);
else
this.collapseMenu(submenu);
};
SDMenu.prototype.expandMenu = function(submenu) {
var fullHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
var links = submenu.getElementsByTagName("a");
for (var i = 0; i < links.length; i++)
fullHeight += links[i].offsetHeight;
var moveBy = Math.round(this.speed * links.length);

var mainInstance = this;
var intId = setInterval(function() {
var curHeight = submenu.offsetHeight;
var newHeight = curHeight + moveBy;
if (newHeight < fullHeight)
submenu.style.height = newHeight + "px";
else {
clearInterval(intId);
submenu.style.height = "";
submenu.className = "";
mainInstance.memorize();
}
}, 30);
this.collapseOthers(submenu);
};
SDMenu.prototype.collapseMenu = function(submenu) {
var minHeight = submenu.getElementsByTagName("span")[0].offsetHeight;
var moveBy = Math.round(this.speed * submenu.getElementsByTagName("a").length);
var mainInstance = this;
var intId = setInterval(function() {
var curHeight = submenu.offsetHeight;
var newHeight = curHeight - moveBy;
if (newHeight > minHeight)
submenu.style.height = newHeight + "px";
else {
clearInterval(intId);
submenu.style.height = "";
submenu.className = "collapsed";
mainInstance.memorize();
}
}, 30);
};
SDMenu.prototype.collapseOthers = function(submenu) {
if (this.oneSmOnly) {
for (var i = 0; i < this.submenus.length; i++)
if (this.submenus[i] != submenu && this.submenus[i].className != "collapsed")
this.collapseMenu(this.submenus[i]);
}
};
SDMenu.prototype.expandAll = function() {
var oldOneSmOnly = this.oneSmOnly;
this.oneSmOnly = false;
for (var i = 0; i < this.submenus.length; i++)
if (this.submenus[i].className == "collapsed")
this.expandMenu(this.submenus[i]);
this.oneSmOnly = oldOneSmOnly;
};
SDMenu.prototype.collapseAll = function() {
for (var i = 0; i < this.submenus.length; i++)
if (this.submenus[i].className != "collapsed")
this.collapseMenu(this.submenus[i]);
};
SDMenu.prototype.memorize = function() {
if (this.remember) {
var states = new Array();
for (var i = 0; i < this.submenus.length; i++)
states.push(this.submenus[i].className == "collapsed" ? 0 : 1);
var d = new Date();
d.setTime(d.getTime() + (30 * 24 * 60 * 60 * 1000));
document.cookie = "sdmenu_" + encodeURIComponent(this.menu.id) + "=" + states.join("") + "; expires=" + d.toGMTString() + "; path=/";
}
};

is that better?

and everything is in functions so it can't get out.
« Last Edit: July 25, 2008, 10:25:56 PM by neostar » Logged

D3xt3r
"Give me the place to stand, and I shall move the Earth"
Global Moderator
Loyal 110MB Member
*****
Online Online

Posts: 2797


/root/D/3/X/T/3/R


WWW
« Reply #11 on: July 25, 2008, 10:42:26 PM »

Have you tried both scripts seperately? Did they both work when alone?

Which one did work, or which one didn't work?

Little more information would be helpful.
Logged




I am not taking project requests at the moment...
I have my own projects and work, please do not request, thank you...
Slittzle
He touched me with noodle appendage
Loyal 110MB Member
*******
Offline Offline

Posts: 2319


©®ªÞ


WWW
« Reply #12 on: July 25, 2008, 10:50:32 PM »

getting a few js errors with the link you posted:
Code:
function sdmenu not returning a value (line 10 -sdmenu.js);
undeclared variable j (line 130 -tablecloth.js)

The scripts may be interfering with each other, and from the looks of it you may not have the full code - because apparently you're missing variable declarations (var j)
Logged

neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #13 on: July 25, 2008, 11:24:57 PM »

D3xt3r - they both work, when they are alone, and when they are together only the last script works, in this case "tablecloth/tablecloth.js".
Slittzle - they give me no errors, maybe because you are not trying them trough my website.
Logged

D3xt3r
"Give me the place to stand, and I shall move the Earth"
Global Moderator
Loyal 110MB Member
*****
Online Online

Posts: 2797


/root/D/3/X/T/3/R


WWW
« Reply #14 on: July 25, 2008, 11:43:25 PM »

D3xt3r - they both work, when they are alone, and when they are together only the last script works, in this case "tablecloth/tablecloth.js".
Slittzle - they give me no errors, maybe because you are not trying them trough my website.

You might not see the errors, but the errors are viewable through a add-on or through error console in certain browsers.. Just because you don't see them, doesn't mean they don't exist. Wink

Its probably a conflict like several people, and Slittzle noted.
Logged




I am not taking project requests at the moment...
I have my own projects and work, please do not request, thank you...
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #15 on: July 26, 2008, 02:51:23 AM »

can someone suggest me a method of checking for intersecting variables?
because as you can see they have a lot of them.
Logged

bind
just a man
Authority Member
****
Offline Offline

Posts: 592


« Reply #16 on: July 26, 2008, 04:52:35 AM »

can someone suggest me a method of checking for intersecting variables?
because as you can see they have a lot of them.

1. look at each file and notice any of the same function names or variable names that may be conflicting

2. open the files up in notepad or your development application, use the find/search function in the program, searching for the function names or variable names that may be conflicting

3. use a file compare utility
Logged

"... if you give a man a fish, he eats today ... if you teach a man to fish, he eats for the rest of his life ..."

That means I am not here to do your work for you, but to assist you in learning how to code what you need. If you want someone to code for you, hire someone to do it or use an out of the box app. All unsolicited pm's are deleted without reading.
neostar
Hyper-Active Member
***
Offline Offline

Posts: 204


WWW
« Reply #17 on: July 26, 2008, 08:04:21 AM »

couldn't find the problem so I moved to another script.
Logged

Pages: [1]   Go Up
  Send this topic  |  Print