Jump to content

Ang3l0fDeath

Members
  • Posts

    47
  • Joined

  • Last visited

    Never

Everything posted by Ang3l0fDeath

  1. For those who want to do the loading of External files http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml function loadjscssfile(filename, filetype){ if (filetype=="js"){ //if filename is a external JavaScript file var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) } else if (filetype=="css"){ //if filename is an external CSS file var fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", filename) } if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref) } loadjscssfile("myscript.js", "js") //dynamically load and add this .js file loadjscssfile("javascript.php", "js") //dynamically load "javascript.php" as a JavaScript file loadjscssfile("mystyle.css", "css") ////dynamically load and add this .css file
  2. #5 was the winner. Simple and easy. Got loading of external files done. However i ran into a Browser cache problem, external files data wasnt up to date and i really got tired of my own alert('test message') showing up even though i deleted it from the external file. I could give #4 a try. But in the long run it would be saving bandwidth with #3 or #5 with also a more secure site.
  3. I've worked on 3 different AJAX run chats, offline and online. Only time i've experienced the browser freezing up was when javascript/AJAX was the cause. If you got page Timers. Test if its the cause by changing the interval between execution. I've only had a timer set to 1 second repeat and my PC usage was at 100% the whole time, and with the chat going and the more messages appeared on the chat, the more laggy my PC got. If you got a function that process alot of data repeatively, related to the timer thingy again, space it out or remove this function tempary to test if the function could be the problem. Also i dont think its your PC / Server / PHP / MYSQL thats the problem. It is also possibly smart to test your AJAX scripts. I suggest you post that information up here and see if anyone notice a problem with AJAX script that could be slightly related to your problem.
  4. Im looking for an example script. I dont need exactly 5 minutes at all, in fact its link to a button. The Example script im looking for will be on a simple loading a javascript file onto the current page where the function are use-able after the file has loaded. I've read 3 different ways, but each sounds like it has own issues. I've also read and thought of using a 4th way on my site. way 1 - AJAX load a page with both the javascript and html content on the page. way 2 - AJAX load just the javascript file into a DIV container way 3 - AJAX load a javascript file and document.create ('script') element and place the file within side the script element. way 4 - iframe/frame to a page that has javascript and html content present, however the javascript within the frame will either work with inside its own frame/page or set it to make changes on the parent page. way 5 - simply just add all the javascript files to my main page. I know some people only done this 1 way, and i was wondering which are the worst approach and which might be the most flexible / reliable. So far i think im going to try way # 4. However when the site is complete i think way # 5 will do fine, thats how a AJAX site is suppose to be. And if anyone curious about the layout of my site. files listed below www.domain.com/index.php - only page anyone will ever look at. www.domain.com/.htaccess - deny access to all dictionarys & files except www.domain.com/ www.domain.com/p=.php - this is the file my AJAX request will be made to, this file will do my GET / POST request and process of all information. This p=.php file will fetch all information from my sub-dictionarys which could be 1 file or hundreds of files.
  5. var input_tag=document.getElementsByTagName("input"); for (i=0; i<input_tag.length; i++){ if(input_tag.type==='checkbox'){input_tag.checked=true;} } // Sorry i couldnt really go though your script and fix it. But i gave you a simple select all checkboxes option above.
  6. Well good job catching up, hope you get around to understanding this stuff. I didnt learn javascript until after i learned PHP. Now everything seems like a second language to me except asp & cgi. 310 lol, your the first to say something like that. Also a small suggestion for your page. Set a background & color in the <body> Plus you can style up the page a bit more with css or <style> Only thing i would really suggest to throw in there CSS wise is padding-right:5; or paddingLeft=5; depending on if your using inline style or not.
  7. You need to give more detail on what you want to do.... yes i know you want to change a link, but how? and do you want to change the link location or the text of the link? And can you give examples of the links you want to change? Also here is a few examples of stuff to look into or change about you function function a_href_update( id, field_name ) { document.getElementById(field_name).value = id; //here i want change the value document.getElementById(field_name).href = new_url; //a href change url location document.getElementById(field_name).value= new_text; //input element value change document.getElementById(field_name).innerHTML= new_text; //a link element change text // I find it confusing you have field_name & id, thats 2 location pointers and you only need 1. // you only need 1 location pointer which generally ID= or Name= or ClassName= // If you do the Name=/ClassName= you still got to go another step to identify location. ID is generally best for a unique ID name. // If you changing lots of links at once do yourself a favor and run it though a loop }
  8. Can i ask what was the name of the class your taking / major your in?
  9. Ya plus i had an extra thought for ya.... like add a start and stop function to your mouse cursor. Cause you can add in the extra feature of adding / changing images. Example. Like you click a button on your page, the mouse cursor would have like an explodion or fireworks, or it simply changes colors from gray to lime green. Well good luck with your site lol
  10. OMG its you again with the name. your really not a javascript person. Anyways im sure this post is old, idk if you still want help or not. But my question to you is. How many shirt Options you got? 1-10? How many shirt Sizes you got? 1-6? Does all your shirts come in all sizes or do some shirts only come in large while others come in all sizes? How many other options of shirt selection are there? Cause really you can make a nice javascript to handle all your data, and your selections. Plus if you got pictures of your shirts, you could also add that into a javascript to display the different shirts each time you change the shirt selection and size as well. Cause simply you and increase an image size or decrease it. Also why are you having problems with the database / page? what is cause the problems? Is it like people selecting multi-checkboxs and you only want them to select one? huh?
  11. elementObject.style //This is how you tell an elementObject its going to be styled in CSS elementObject.style.color='white';// OR ='#ffffff'; elementObject.style.backgroundColor='red';// OR ='#800000'; elementObject.style.padding=5; elementObject.style.textAlign='center'; hopefully thats enough examples for you to understand it.
  12. Nice username. However im confused on what your trying to say. wraping text is easy. http://www.w3schools.com/css/pr_text_white-space.asp If your trying to count the length of your input try. http://www.w3schools.com/jsref/jsref_length_string.asp
  13. You'll have to forgive me not giving you an exact working example. Im giving you the framework you need. I could give you a better code and more helpful code if i have some additional information. where is the timer on your page? and big is the timer section like 20x20? 40x40? 60x60? 80x80? Also i suggest you put a clock with the timer, its very helpful in allowing a person to know the time and when they should be done. Also what type of exam is this and whats it for? Javascript is helpful with user-friendly functions, but there could be a security problem if you relay 100% on javascript to handle the whole timing of the exam. Reason why i say javascript could have a security issue is cause anything and everything javascript could be hacked since its on the client user end. // create a function to start your timer. // page onload event works best // button onclick works well too. var mins_limit = 45;//personally i use seconds cause its more accurate var limit_seconds = mins_limit*60;//see i made a seconds thingy. var start_time = 0;//This varible is the start of the 45 minutes. function start_timer(){ // i stopped my work here cause idk what you got to work with. Setting a timer is easy, but you still got to output the varibles into elements/fields which with a simple timer you only need 1 output area, but if you want something a bit more like i said above it could take 4-6 id fields and a bit more functions / math / work. }
  14. I have a webpage that has tons of data as well.... best way i found to edit data or save data is to do it though javascript. Javascript greatly reduced the code on the page, the reason why is the only function i had was <tr><td><input type=button value='Save' onclick="save_data(this);"> I hope you know what ( this ) is, is so read up on it. This will result in an elementObject of the input field. But use your nodes. elementObject.parentNode.parentNode. alert the results of the elementObject that results for each part and stop at the HTML - TR node. After that you can evaluate data each INPUT field or TD field within the TR element. If your understanding why im suggesting this you might find it useful in processing your data back into a AJAX thingy. Personally i would loop each input field into a query string and send that string back to a page that is just meant to recieve data. However you can use the CURRENT page to recieve the data. HOW? Well in PHP you divid your page. 1 page would be recieving POST/GET request. Another would be the output of the normal page which is ur current page. From what i see your good enough with ajax/css/probably php and a few other languages to figure out what solution you need and how to make it work. I hope something here helped.
  15. <a href="javascript:addEducation('?id=3');"> function addEducation(url_query){ alert(url_query);// to test //window.location.href=url_query; // this will forward the page to your url }
  16. You can put a box around the mouse cursor. i would suggest a box.gif image for the box though. function mouse_p(x_or_y){if (!e) var e = window.event; var posx = 0; var posy = 0; if (e.pageX || e.pageY){ posx = e.pageX; posy = e.pageY;} else if (e.clientX || e.clientY){ posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;} if(x_or_y==='y'){return posy;} if(x_or_y==='x'){return posx;} The code above will get the mouse location within the window your webpage is located. This is used to get the X & Y location of your mouse, hope you remember algerbra for X & Y. lol Alright this part you will have to figure out how to do yourself next. But you looking for a way to start your function, this can be done by a button or <body onload='start_function_1'> /* start_function(){ // get the y & x location of the mouse var x = function mouse_p('x'); var y = function mouse_p('y'); // have a DIV field somewhere, with an position=absolute / position:absolute; left:0; top:0; width:0; height:0; // you might have to change size to fix your image height/width but DIV if i remember expands to fix the size of whatever content it has. // no we are going to change the DIV position left:x; top:y; OR left:function mouse_p('x'); top:function mouse_p('y'); // So now your Div moved to where the mouse is. // However to keep the box moving with the mouse we got to constantly repeat this function start_function_1() repeatively. You can set it to just excute again or set it on a timer. But the more delayed the responce time of the function the more laggy it looks. Also if this script is just excuted again at 0 mill-seconds it could lag up someones computer. So be careful. Some functions do some dont. } */
  17. Yep best to use Quotes around a function onclick like event. <input type=button value=show onclick="test();"> Additionally you could add data into your function. like onclick="test('data')" A good use of inputting data is to tell test a location/place like an element ID which is useful if you want to test specific check-box fields, if you want to test multi check-box fields at once, i suggest running it through a for() - loop by getElementByTagName('input').[x] - x being a nubmber, generally for(x=0; getElementByTagName('input')>x; i++){/*Add a if function that only evaluates check-boxs instead of all input fields now. Example If(getElementByTagName('input').type==='checkbox'){ //Do your stuff here to check your multi checkbox field// }*/} <input type=button value=show onclick="test('');"> Sorry about running on with all the extra info. Just trying to spread ideas.
  18. I'm Posting Here regarding a way to format numbers like in PHP with number_format. Here is my javascript verison i wrote yesterday. Hope it helps you guys who are looking. This is simply to add commons & mine is only for positive numbers. function number_format(input_){ if(input_>0){var input_string=input_.toString();var rebuild='';var rebuild_remaining=input_string; var loop_='no'; for(i=0; rebuild_remaining.length>3; i++){loop_='yes'; rebuild = rebuild_remaining.substr((rebuild_remaining.length-3),3)+','+rebuild; rebuild_remaining=rebuild_remaining.substr(0,(rebuild_remaining.length-3)); }if(loop_==='yes'){rebuild = rebuild_remaining+','+rebuild; rebuild = rebuild.substr(0,(rebuild.length-1));}else{rebuild=input_string;} return rebuild;}else{return 0;}} Simple way to understand this code, you input a pure number, not a string. the number is turned into a string inside this function so it can count the length of the string, you cant count the length of a number. Secondly i installed a loop that will loop though our number string and slowly subtract 3 end digit numbers at a time and adding a , (comma) after each. The string is being rebuild into a new varible which is later edited with the correct formating and removing an extra comma from the end of the process. So far i havent had 1 problem with this script and it works amazing with my other function that does the var cost = price * amount; var cost = number_format(cost); document.getElementById('div_id').innerHTML=cost; document.getElementById('input_id').value=cost; Again i hope this helps
  19. Trust me the function is running. just fine. it starts and runs just fine. All it does is collect data, put that into a cookie, the cookie is used in Start_Timer(); and start_timer works just fine, it counts up or down. So ya it works. Just moving that small piece of code i want is impossible. like i said this is an oddball problem that shouldnt exist.
  20. Not a darn thing, however i think it has something to do with the cookie, or the loop. Maybe i should individually test each by itself maybe. But thanks for the help, you can see why im having a slight problem, its not an easy fix and makes no-sense at all. Mean time im going to have lunch then play cards with the family so i'll be back later. If you come up with any other ideas i'm all ears, hopefully someone else gots an insight to why this magical error happens without an error being present.
  21. else{alert('problem');} Both the if and else both dont excute. like i said earlier deadzone.
  22. Copied and pasted your last post. checked for javascript erros and none, and yet again it doesnt work. i love how easy it is to test that.
  23. Exactly i want start_timer to start regardless. I want to add it at the end of the function as before the last bracket in the function which closes the function. But it just doesnt want to work there. I got another function where i have a similar problem with the End Brackets being an issue.
  24. Well hopefully you understand the whole thing, but ya good luck understanding it. function get_user_info(){ for (i=0; i<(document.getElementsByTagName("table").length); i++){var table_temp=document.getElementsByTagName("table")[i]; /* PM SECTION - START - Includes MP3 AUDIO ALERT IF MESSAGE*/ if(table_temp.rows[0].cells.length==2){ if(document.getElementsByTagName("table")[i+1].rows[0].cells[0].innerHTML.search("Income")>0 && document.getElementsByTagName("table")[i+1].rows[0].cells[2].innerHTML.search("Private Messages")>0){ if(table_temp.rows[0].cells[0].innerHTML.search("i/w/blink.gif")>0){ /* CREATING DIV */ var newdiv = document.createElement('div'); /* CREATING DIV */ newdiv.setAttribute("ID","mp3_mail"); newdiv.style.visibility="hidden"; /* CREATING DIV */ newdiv.style.position="absolute"; /*absolute//relative*/ newdiv.style.left=0; newdiv.style.top=0; /* FINISH DIV */document.body.appendChild(newdiv);/* FINISH DIV */ document.getElementById("mp3_mail").innerHTML="<embed width=0 height=0 hidden='true' autostart='true' volume='100' loop='false' src='"+mp3_mail+"'>";} /* PM SECTION - END */ /* USER BAR INFO - START */ //alert(document.getElementsByTagName("table")[i+2].rows[0].cells[0].innerHTML); var user_money = document.getElementsByTagName("table")[i+2].rows[0].cells[0].innerHTML.replace(/^\s+|\s+$|,/g,"").replace(" $",""); var user_food = document.getElementsByTagName("table")[i+2].rows[0].cells[2].innerHTML.replace(/^\s+|\s+$|,/g,"").replace(" F",""); var user_power = document.getElementsByTagName("table")[i+2].rows[0].cells[4].innerHTML.replace(/^\s+|\s+$|,/g,"").replace(" P",""); var user_turns = document.getElementsByTagName("table")[i+2].rows[0].cells[6].innerHTML.replace(/^\s+|\s+$|,/g,"").replace(" T",""); var user_server = document.getElementsByTagName("table")[i+2].rows[0].cells[8].innerHTML.replace(/^\s+|\s+$|,/g,""); var user_name = document.getElementsByTagName("table")[i+2].rows[0].cells[10].innerHTML.replace(/^\s+|\s+$|,/g,""); // 7 - - ;if(document.getElementById("current_turns")){document.getElementById("current_turns").innerHTML=user_turns;} if(user_server==='RT'){ var server_speed=8; var server_max_turns=30;} if(user_server==='Ultra'){ var server_speed=120; var server_max_turns=100;} if(user_server==='Fast'){ var server_speed=300; var server_max_turns=150;} if(user_server==='Normal'){var server_speed=900; var server_max_turns=180;} if(user_server==='Slow'){ var server_speed=1800;var server_max_turns=250;} user_turns = current_time('U')-(user_turns*server_speed); /////////////////////////// var build_server_userbar = 'username|'+user_name +'[#]money|'+user_money +'[#]food|'+user_food +'[#]power|'+user_power +'[#]turns|'+user_turns +'[#]server|'+user_server +'[#]server_speed|'+server_speed +'[#]server_max_turns|'+server_max_turns; setCookie('user_server_info',build_server_userbar,365);if(document.getElementById("header_sub")){start_timer();} //document.getElementById("header_sub").innerHTML=getCookie('user/server_info'); } } } }
  25. Thats it, nothing shows up. Script runs just fine all the way down to the last action which is to write a setcookie. After that i either have the start_3(); behind the setcookie. like so. setCookie('user_server_info',build_server_userbar,365);if(document.getElementById("header_sub")){start_timer();} } } // This is where i want to place if(document.getElementById("header_sub")){start_timer();} but it wont work here. but it works just fine where its at currently, seriously WTF }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.