Hi everyone. I have some questions, which should be rather easy to reply, but as I am working on PHP, JavaScript, XML, CSS, Photoshop and other stuff at the same time, my head, which is about to explode, would be grateful for any answers :).
1) I have created a simple navigation system which loads local html documents on a main big DIV element in my page. Although greek language (iso-8859-7) is working outside that DIV, inside it i see question marks. My HTML files only contain <div>..More elements..</div>. I have tried calling complete HTML documents (with html, head, body etc elements) but no luck. Is that approach wrong? Any ideas why this happens?
2) I use JavaScript to dynamically generate gadgets on the sidebar of my page with the document.create Element() and SomeElement.app endChild() methods. Whatever element wasn't originally on the page though (the divs I create), gives a "parentObj is not defined" error when i remove it, but the result is ok. It seems like the document element content needs to be copied to the browser memory and be refreshed... - function addSidebarElement() {
-
var ni = document.getElementById('gadgets');
-
var numi = document.getElementById('theValue');
-
var num = (document.getElementById('theValue').value -1)+ 2;
-
numi.value = num;
-
var newdiv = document.createElement('div');
-
var divIdName = 'newgadget'+num;
-
newdiv.setAttribute('id',divIdName);
-
newdiv.setAttribute('style','display: none;');
-
newdiv.innerHTML="<h2 onclick=\"Effect.toggle('"+divIdName+"Content','blind')\">"+divIdName+"</h2><ul id=\""+divIdName+"Content\"><li><a href=\"#\">Fusce dui neque fringilla</a></li></ul><span onclick=\"removeElement(this);\">Remove Gadget</span>";
-
ni.appendChild(newdiv);
-
-
Effect.SlideDown(divIdName);
-
}
-
-
function removeElement(divObj) {
-
var parentObj = document.getElementById('gadgets');
-
var childObj=divObj.parentNode;
-
var divId=childObj.getAttribute('id');
-
Effect.SlideUp(divId);
-
-
setTimeout("parentObj.removeChild(childObj)",2000);
-
}
Any explanations? I am worried that this problem is gonna make it worse after I add more stuff dynamically...
6 2559 acoder 16,027
Recognized Expert Moderator MVP
Changed the thread title to something more meaningful.
Does this error occur on the setTimeout?
Probably not because it was the same before I added that line. I think it's line 17. It seems that the second function can't call any element by it's id. :/
And I can't change the topic title. (???)
Look at your modified Code.
I did it. -
var parentObj = null; //Defined here.
-
function addSidebarElement() {
-
var ni = document.getElementById('gadgets');
-
var numi = document.getElementById('theValue');
-
var num = (document.getElementById('theValue').value -1)+ 2;
-
numi.value = num;
-
var newdiv = document.createElement('div');
-
var divIdName = 'newgadget'+num;
-
newdiv.setAttribute('id',divIdName);
-
newdiv.setAttribute('style','display: none;');
-
newdiv.innerHTML="<h2 onclick=\"Effect.toggle('"+divIdName+"Content','blind')\">"+divIdName+"</h2><ul id=\""+divIdName+"Content\"><li><a href=\"#\">Fusce dui neque fringilla</a></li></ul><span onclick=\"removeElement(this);\">Remove Gadget</span>";
-
ni.appendChild(newdiv);
-
-
Effect.SlideDown(divIdName);
-
}
-
-
function removeElement(divObj) {
-
parentObj = document.getElementById('gadgets'); //Redefined here.
-
var childObj=divObj.parentNode;
-
var divId=childObj.getAttribute('id');
-
Effect.SlideUp(divId);
-
-
setTimeout("parentObj.removeChild(childObj)",2000);
-
}
Now test this, I think it will work.
Good Luck.
Kind regards,
Dmjpro.
Thanks Dmjpro. Unfortunately, with this modification, the error remains, while the added element is not removed. :(
Found it. I removed the scriptaculous effect and now no error, but unfortunately no effect.
The new code: - function removeElement(divObj) {
-
var parentObj = document.getElementById('gadgets');
-
var childObj=divObj.parentNode;
-
var divId=childObj.getAttribute('id');
-
//Effect.SlideUp(divId);
-
parentObj.removeChild(childObj);
-
//setTimeout("parentObj.removeChild(childObj)",2000);
-
}
I'll keep you posted on the progress...
By the way, whats the difference of creating a scriptaculous effect with - new Effect.EffectName('divid');
and - Effect.EffectName('divid');
???
You can do one more thing with my Code.
As parentObj defined outside you can define childObj as well. -
var parentObj = null; //Defined here.
-
var childObj = null; //Defined here.
-
function addSidebarElement() {
-
var ni = document.getElementById('gadgets');
-
var numi = document.getElementById('theValue');
-
var num = (document.getElementById('theValue').value -1)+ 2;
-
numi.value = num;
-
var newdiv = document.createElement('div');
-
var divIdName = 'newgadget'+num;
-
newdiv.setAttribute('id',divIdName);
-
newdiv.setAttribute('style','display: none;');
-
newdiv.innerHTML="<h2 onclick=\"Effect.toggle('"+divIdName+"Content','blind')\">"+divIdName+"</h2><ul id=\""+divIdName+"Content\"><li><a href=\"#\">Fusce dui neque fringilla</a></li></ul><span onclick=\"removeElement(this);\">Remove Gadget</span>";
-
ni.appendChild(newdiv);
-
-
Effect.SlideDown(divIdName);
-
}
-
-
function removeElement(divObj) {
-
parentObj = document.getElementById('gadgets'); //Redefined here.
-
childObj=divObj.parentNode;
-
var divId=childObj.getAttribute('id');
-
Effect.SlideUp(divId);
-
-
setTimeout("parentObj.removeChild(childObj)",2000);
-
}
Good Luck.
Kind regards,
Dmjpro.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Liang |
last post by:
Hi,
I use "defined $r_libs->{$name}" to check first if a key exists in a hash
table. But Perl gives a warning WHENEVER the key exists: "Use of
uninitialized value".
Would u please help to check the script, and let me know the reason? Thanks
in advance.
Liang
|
by: Dmitry |
last post by:
Hello,
Sometimes on js code execution Mozilla 1.5
prints in JS concole the following error:
"Error: fn is not defined"
where "fn" is the function name surely defined _before_ the line
that produces error. The fn body and error line both live
in the same *.js file.
|
by: MLH |
last post by:
I copied the following code snippet from A97 HELP. Am
getting an error at compile time suggesting there's a problem
with the first line (compile error, user-defined type not defined).
It is likely that I've left something out. Doesn't seem to like Dim
dbs as Database - that's what's hi-lited after acknowledging the
error. Can you see anything wrong with that syntax?
Dim dbs As Database, rst As Recordset
Dim rstEmployees As Recordset,...
|
by: david |
last post by:
When I compile a window form client for web service, there is error message
as follows:
Program
'D:\usr\winVBcontrol\WinClient4WebServiceFileCS\obj\Debug\WinClient4WebServiceFileCS.exe' does not have an entry point defined
Notice: I create a solution (perhaps for VB). In the sulotion, I created win
form clients for web service with VB in a window form VB project and they
worked fine. Now the current one is developed in a C# project under...
|
by: Eric G. Harrison |
last post by:
We have a project with many other projects referenced (all of which are referenced at the project level and are included in the solution). Frequenly, if we make a change in project A (such as adding a property, or even simply changing a line of code), a form in project B will then show 10 or more "object such-and-such is not defined". To fix this problem we check out the form in project B and 90% of the time that fixes it (but nothing changes...
| |
by: Yannick Turgeon |
last post by:
Hello,
I'm using A97 (french version) on XP (english version).
Since this afternoon, all the Access built-in french-equivalent
function are generating a "Sub or Function not defined" error. An
exemple: IIf(1=1,"bob","joe") is ok but it's french equivalent
VraiFaux(1=1,"bob","joe") generates the error.
It's not linked to the PC since other applications with this function
|
by: Yarik |
last post by:
Hello,
I am not sure the subject of my post adequately describes the problem I
am trying to solve, so I think a specific example would be helpful.
Let's say there are XML descriptions of products like this one:
<!-- File: Products.xml -->
...
<Product id="p1">
|
by: KelHemp |
last post by:
I have compiled data from 13 tables, one for each month of the year that hold 45 fields each, and another for employee information, that holds 16 fields. The database is intended to record hours and special pay withholdings.
I split up the report into First Half and Second Half, as the paper version we use currently does.
My report First Half let me create control boxes for each field I wanted to include, however, when I try printing or...
|
by: chenxinleo |
last post by:
Hi,
When i use some standard library functions and fields,which return
char* type(like ctime in time.h, optarg in getopt.h)and do not have to
be freed after calling,i always worry about memory leaking(thoug i
konw i just donot have to).Then i look inside in time.h
file(mingw) ,and i found notes say"These functions write to and return
pointers to static buffers that may be overwritten by other function
calls".So how is the"static buffers"...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |