RichardRotterdam
Members-
Posts
1,509 -
Joined
-
Last visited
Everything posted by RichardRotterdam
-
heh well what do you know haven't even bumped into that one before. but yeah that one would be simpler
-
Use setTimeout and call it self so it will be periodical. like so: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript"> var timepassed = 0; function periodical(){ var interval = 2000; timepassed += interval; $("#time").text(timepassed); // let it call it self so there is an endless loop setTimeout ( "periodical()", interval); } jQuery(document).ready(function(){ periodical(); }); </script> <b>msec passed:</b> <div id="time"></div>
-
I took a look at your code to see what it does and I see what you're trying to do. I'm not going to touch it though it doesn't look that pleasant with all the embedded events and non indented code. Here is something that might be able to help you on your way. Read the comments and either firebug or change the console.log to alert to see what happens. Hope it helps <style> #myform legend{ font-weight:bold; } #myform label{ width:220px; display:block; } </style> <script type="text/javascript"> // wait for the page to be loaded (look into domready if you can its better) window.onload = function() { // get checkbox elements by name attribute var checkboxes = document.getElementsByName("actor"); // add onclick even for the checkboxes for(var i = 0; i< checkboxes.length; i++){ var checkbox = checkboxes[i]; //used closure to return the index here otherwise it would just always return the highest number checkbox.onclick = (function(index){ return function(){ //shows the current element clicked into firebug console console.log(this); // returns the index of the checkbox console.log("checkbox clicked with index:"+ index); //show status console.log("the status of the checkbox is now: "+this.checked); } })(i); } } </script> <form id="myform"> <fieldset> <legend>Which shall thou honor into the hall of shame</legend> <label><input type="checkbox" name="actor" value="Mr-T" />Mr-T </label> <label><input type="checkbox" name="actor" value="Chuck Norris" />Chuck Norris</label> <label><input type="checkbox" name="actor" value="Lorenzo Lamas"/>Lorenzo Lamas</label> <label><input type="checkbox" name="actor" value="Bob Saget"/>Bob Saget</label> <label><input type="checkbox" name="actor" value="Will Smith"/>Will Smith</label> <label><input type="checkbox" name="actor" value="Ben Stiller"/>Ben Stiller</label> </fieldset> </form>
-
notice something wrong here? <script type="text/javascript"> src="jquery.js"></script> You're closing the opening script tag prematurely. Use firebug for firefox to see js errors or any other javascript debugging tool. It would have shown you the error.
-
urgent help alert even and odd numbers with for loop please
RichardRotterdam replied to xcoderx's topic in Javascript Help
this is one of the things that might caused it onclick="eve() when your function name is even -
urgent help alert even and odd numbers with for loop please
RichardRotterdam replied to xcoderx's topic in Javascript Help
You probably would have seen some trouble by just indenting your code. function even() { var even even = document.results.even.value; var even=0; for (even=1;even < 50;even++) { alert(even); } // see something missing here? function odd() { var odd odd = document.results.odd.value; var odd=0; for (odd=1;odd < 20;odd++) { alert(odd++); } // see something missing here? -
You could but don't see any way to do this without javascript though. Unless there is a way you could simply turn of javascript to post anyway. but something like this could work if there were a ton of links in it: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"></script> <script type="text/javascript"> window.addEvent('domready', function() { var urls = ['www.php.net','php.net','www.php.net/manual/en/index.php']; var known = []; urls.each(function(url) { var anchor = new Element('a', { 'href': 'http://' + url, 'class':'checkme', 'html':url, 'styles' : { 'display': 'none' } }).inject($(document.body)); if(anchor.getStyle('color') == '#551a8b') { known.include(anchor.get('text')); } }); if(known.length == 0){ window.location.href = "http://seeasea.files.wordpress.com/2009/04/rtfm1.jpg"; } else { alert ("good boy!"); } }); </script>
-
http://www.didyouwatchporn.com/ I stumbled upon an article about spyjax (using ajax to see what links have been visited) and thought this one was quite entertaining. And yeah were you guilty?
-
Maybe change the ( to { after body
-
passing a variable to the url in with the serialize function
RichardRotterdam replied to co.ador's topic in PHP Coding Help
A couple of questions for you: What does code (html/php) of your form look like? What type of data is " $arrRestaurants"? Why do you need serialize()? -
need help in how to get and display text from xml using ajax
RichardRotterdam replied to doforumda's topic in Javascript Help
Here is one thing I notice. This: XHRO.onreadystatefunction = function() This: XHRO.onreadystatechange = function() -
PHP Ajax Live Search - Extract MySQL data
RichardRotterdam replied to craiglaw2504's topic in Javascript Help
Well starting with one from scratch sure would be the most education way to go. If you want the easy way out I suggest trying it using a javascript framework mootools autocomplete: http://digitarald.de/project/autocompleter/ jquery autocomplete: http://docs.jquery.com/Plugins/Autocomplete otherwise just lookinto ajax and see how far you can get -
Not exactly sure what you mean but let me explain the code a bit. in the html you will see the following: <fieldset id="type_checkboxes"> <label>Type 1: <input type="checkbox" name="type[]" value="1" /></label> <label>Type 2: <input type="checkbox" name="type[]" value="2" /></label> <label>Type 3: <input type="checkbox" name="type[]" value="3" /></label> <label>Type 4: <input type="checkbox" name="type[]" value="4" /></label> <label>Type 5: <input type="checkbox" name="type[]" value="5" /></label> <label>Type 6: <input type="checkbox" name="type[]" value="6" /></label> </fieldset> <label>Check all: <input type="checkbox" name="checkall" id="checkall" /></label> All the type checkboxes are grouped inside a fieldset element using "type_checkboxes" as id. You will notice the "Check all" checkbox is outside this fieldset which is good because it has a different functionality then the regular type checkboxes. now in the JS there is the following line: var type_checkboxes = document.getElementById("type_checkboxes").getElementsByTagName("input"); What this line does is find all input elements within the fieldset element. If you have firebug for firefox and try this: console.log(type_checkboxes) You will see that is a collection of the type checkboxes.
-
PHP Ajax Live Search - Extract MySQL data
RichardRotterdam replied to craiglaw2504's topic in Javascript Help
What part are you stuck on? If the example link is nearly what you require couldn't you change the script so it would do what you require? -
Actually in that example i posted all the name attributes are the same except for the "Check all" checkbox. But the value of that checkbox you dont require for submitting anyway so it probably should be the way to go. Your biggest difficulty will be unchecking/checking the "Check all" checkbox when checking/unchecking the type checkboxes
-
@Omzy Got it now Here is a startup for a Unobtrusive vanilla javascript <script type="text/javascript"> window.onload = function(){ var type_checkboxes = document.getElementById("type_checkboxes").getElementsByTagName("input"); // add events for all checkboxes inside the type_checkboxes container for(var i = 0; i < type_checkboxes.length; i++) { var checkbox = type_checkboxes[i]; // check if the "check all" status needs to be changed checkbox.onclick = function() { alert("the checked status of the clicked element has changed to: "+ this.checked); } } // add event for checkall checkbox var checkAll = document.getElementById("checkall"); checkAll.onclick = function(){ alert("the checkall checkbox status has changed to :" + this.checked); } } </script> <form> <fieldset id="type_checkboxes"> <label>Type 1: <input type="checkbox" name="type[]" value="1" /></label> <label>Type 2: <input type="checkbox" name="type[]" value="2" /></label> <label>Type 3: <input type="checkbox" name="type[]" value="3" /></label> <label>Type 4: <input type="checkbox" name="type[]" value="4" /></label> <label>Type 5: <input type="checkbox" name="type[]" value="5" /></label> <label>Type 6: <input type="checkbox" name="type[]" value="6" /></label> </fieldset> <label>Check all: <input type="checkbox" name="checkall" id="checkall" /></label> </form> The difficulty of the js depends on wether or not the amount of types is dynamic. For example you want to have 10 types selectable instead of just 2. If it's just 2 types you could pretty much pull it all off with mostly the document.getElementById() function. If the types will be dynamic or quite a few your better of using a loop and attaching events like in the example.
-
Then in that case why not have a single select all checkbox which either checks all values when checked and unchecks all checkboxes when unchecked. From a usability point of view I see more confusion with your original idea rather then using javascript to improve usability.
-
You could just make it radio buttons instead of checkboxes that wouldnt require any javascript and would do the same thing. <input type="radio" value="all" />All types <input type="radio" value="type1" />Type 1 <input type="radio" value="type2" />Type 2
-
how does that relate to your topic tittle "Re: How do I use a global footer..?" Can't you use a footer include?
-
<select onchange="gotoUrl(this.value)"> <option value="#">select a location</option> <option value="http://www.chucknorris.com">chuck norris</option> </select> all you basically need is window.location in js
-
how to getvalue from textbox without submitting ?
RichardRotterdam replied to chennaibala's topic in Javascript Help
try looking into ajax -
how to getvalue from textbox without submitting ?
RichardRotterdam replied to chennaibala's topic in Javascript Help
You can't get a value of a textarea without submitting with PHP. You could with javascript though. -
Ajax AutoSuggest Search using PHP / MS Access DB
RichardRotterdam replied to mjs87's topic in Javascript Help
If you searched for "Ajax PHP autocomplete" or something along those lines then it should be pretty much those tutorials. As stated before you just need to know how to connect to an MS Acces database using odbc_ functions, PDO or something else that might work with MS Access. The tutorials written for mysql should otherwise be pretty much the same except for the database handling. What code have you got so far and what tutorials have you tried? Simply asking for tutorials that will point you to the right direction for "PHP MS Access" comes off as if you haven't done enough research yourself thus having the result that people are less willing to help you out on your problem. -
Mind Blowing Hyperrealistic Sculptures
RichardRotterdam replied to nrg_alpha's topic in Miscellaneous
Those sculptures remind me of the bread shaped in human parts. http://www.youtube.com/watch?v=GKSO7m3-MH8 Not sure if I got that link for here though. -
A description about what it exactly is that isn't working and when along with what errors you might receive would be helpful. Just dumping your complete html page and expecting someone to figure out what your problem is not likely going to get you help any time soon.