Jump to content

chrici

Members
  • Content Count

    31
  • Joined

  • Last visited

Community Reputation

1 Neutral

About chrici

  • Rank
    Newbie
  • Birthday 05/10/1992

Previous Fields

  • Languages
    (X)HTML, CSS, Javascript, PHP

Contact Methods

  • Website URL
    http://
  • ICQ
    0

Profile Information

  • Location
    Denmark
  1. Oh yeah thanks! :)Then I think I will try an AJAX/PHP solution.
  2. I have an XML file and I want to manipulate it from user input and save the changes to the same file. Is this possible with javascript? I know how to load the XML file and manipulate the nodes but not how to save it. I have tried to search google and the forums aswell as reading the tutorials but I have not been able to find anything
  3. Because that I am the kind of person who learns by trying. This code is not for a client or a site.I read about event targeting some time ago and thought that I would like to learn it
  4. You need to declare that it is a string in your javascript code.Otherwise javascript will think it is an integer or a variable. To declare it as a string put quotation marks around it: jsvar = "<?php echo $tempvar; ?>";
  5. I tried to do it but it is not working.I am not passing anything into the functions event parameter. I am just doing what I have seen other sites do.
  6. I have the following code. <!DOCTYPE html><html> <body> <p id="clickme">Click me!</p> <div id="new"></div> <script type="text/javascript"> document.onclick = function(event) { target = event.target || event.srcElement; if (target.id == 'clickme') { paragraph = document.createElement('p'); content = document.createTextNode('This is a test...'); paragraph.appendChild(content); document.getElementById('new').appendChild(paragraph); } } </script> </body></html> When the paragraph id="clickme" is clicked a child paragraph should be appended to id="new". This works in all browsers except for prior versions of IE than 9. I do not know which prior versions it is since I am using the compability mode in IE9 to test. Using Firebug Lite for IE I receive this error when id="clickme" is clicked:"Unable to get value of the property 'target': object is null or undefined"I don't know how to fix this error and why it occurs. Please help me.
  7. You should read this tutorial: http://www.w3schools.com/js/js_timing.asp :)You can delay a function using setTimeout. function popups() { setTimeout('alert(first)',1000); setTimeout('alert(second)',5000); setTimeout('alert(third)',10000);} When called this function will display the first alert after 1 second (1000 milliseconds), the second alert after 5 seconds and the third alert after 10 seconds.
  8. You say that you are using the onkeyup event but in the code you are using the onkeydown event. Change that to onkeyup and I think it will work.
  9. I would suggest that you read the MySQL part of the PHP tutorial.http://www.w3schools.com/php/php_mysql_intro.aspIn the tutorial you will learn to handle a MySQL database.
  10. string.style.color; This is a property of the string and will (if declared) output the current color of the string. In order to change the color you need to assign the property with a value. For instance: string.style.color = "red";
  11. Try to declare the desired font size.I can see that the font-size is 14px in Chrome, 13.5px in Firefox and 13px in Opera.
  12. Yes - now it is working.And thank you very much!!
  13. Yes - much easier.But it is still not working.I changed the anonymous function to: function(newelement,newtext) { newtxt = document.createTextNode(newtext); newel = document.createElement(newelement); newel.appendChild(newtxt); parent = this.parentNode; first = parent.firstChild; this.insertBefore(newel, first);}; The console in Chrome gives me the following message:Uncaught TypeError: Cannot read property 'firstChild' of undefinedI guess that there is something wrong with the use of "this"?
  14. Hi all.I am learning javascript and therefore I create my own javascript experiments to learn it.In my latest experiment I want to append an element as the first child instead of the last.I managed to make it work but I also want to learn how to use objects aswell. This is the triggy part...I know this can be done with JQuery but I want to learn how to do it myself.Hope that you can help me :)This is the code: <!DOCTYPE HTML><html> <head> <title>Javascript test</title> <script type="text/javascript"> function element(element) { this.elementType = element; this.appendAbove = function(newelement,newtext) { newtxt = document.createTextNode(newtext); newel = document.createElement(newelement); newel.appendChild(newtxt); parent = this.parentNode; childNodes = parent.childNodes; for (i=0;i<childNodes.length;i++) { window['clone'+i] = childNodes[i].cloneNode(true); parent.removeChild(parent.childNodes[i]); } parent.appendChild(newel); for (x=0;x<i;x++) { parent.appendChild(window['clone'+x]); } }; } </script> </head> <body> <h1>Test site...</h1> <section> <p>This is just a sample text...</p> <p>This is another sample text...</p> </section> <script type="text/javascript"> var str = new element(document.getElementsByTagName('p')[0]); str.appendAbove('p','Yeah - it works!'); </script> </body></html>
  15. chrici

    Require function

    Just found the the problem :)In the included file I am including another file. It is the path to the second included file that was problem.Thanks for your help!
×
×
  • Create New...