Jump to content

amelio

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by amelio

  1. Thanks kicken, I think that's what I might have to do. It's a real pain as to have someone click on the same option seems useful in some circumstances. It's very frustrating because it works fine as it is in ie and ff. I'm trying to think around the possibility that when any option in the selection list is clicked then returning the value of that option and if that value equals random_20 then firing the function. It still wouldn't work with .change because if the user was clicking the same option succesively then there is no change event. Thank you also fastol, the problem with your solution is that we never fire the $('#sel_list').change(function() because if a user clicks the same option there is no change event.
  2. Hi, I have a select list, when a user chooses random_5, if they don't like the choice that is automatically made I would like them to be able to choose this option again. The problem is Chrome doesn't recognise .click on the option element on line 48 of the fiddle. It is well documented on this and other sites that you should use .change on the select element. The problem for me is, if a user chooses random_5 after having chosen it before there is no change and the event isn't fired. I have a fiddle http://jsfiddle.net/4gEFh/2/ Any help greatly appreciated. <select id="sel_list"> <option value="clear_all">Clear All</option> <option value="select_all">Select All</option> <option value="random_5">Random 5</option> </select> <br/> <br/> <input type="checkbox" value="ruddy" /> Ruddy<br/> <input type="checkbox" value="garrido" /> Garrido<br/> <input type="checkbox" value="bennett" /> Bennett<br/> <input type="checkbox" value="johnson" /> Johnson<br/> <input type="checkbox" value="pilkington" /> Pilkington<br/> <input type="checkbox" value="wolfswinkle" /> Wolfswinkle<br/> <input type="checkbox" value="hooper" /> Hooper<br/> <input type="checkbox" value="fer" /> Fer<br/> <input type="checkbox" value="snodgrass" /> Snodgrass<br/> <input type="checkbox" value="martin" /> Martin<br/> <script> $(document).ready(function(){ $('#sel_list').change(function() { if ($(this).val() === 'clear_all') { $('input[type="checkbox"]:checked').removeAttr('checked'); } if ($(this).val() === 'select_all') { $("input[type=checkbox]").prop('checked', true); } }); }); $(document).ready(function(){ function getRandomArrayElements(arr, count) { var randoms = [], clone = arr.slice(0); for (var i = 0, index; i < count; ++i) { index = Math.floor(Math.random() * clone.length); randoms.push(clone[index]); clone[index] = clone.pop(); } return randoms; } //Dummy array function createArray(c) { var ar = []; for (var i = 0; i < c; i++) { ar.push(i); } return ar; } //check random checkboxes function checkRandom(r, nodeList) { for (var i = 0; i < r.length; i++) { nodeList.get(r[i]).checked = true; } } //console.log(getRandomArrayElements(a, 10)); $(function() { var chkCount = 10; //this can be changed var numberOfChecked = 5; $("option[value=random_5]").on('click',function(e) { var chks = $('input[type=checkbox]'); chks.attr("checked", false); var a = createArray(chkCount); var r = getRandomArrayElements(a, numberOfChecked); checkRandom(r, chks); }); }); }); </script>
  3. Hi, I have a domain registered for a client pointing to a holding page. The strange thing is I can't access it from home where my isp is aol, I have cleared the browser cache, cleared router cache but still to no avail. I can access the site on my mobile over the network but not when it is connected to the wifi. I contacted aol customer support and they couldn't access the site either. He told me that they don't use aol as their isp there but I guess they might well be using aol nameserver information. I don't know. If any one can shed any light on this I would be very grateful. The site is www.cidervinegarhealth.net Thanks
  4. Hi, I have a page with a long list of names (c1000) each with an id. On that page I would like to have a form into which i put the id number, when the form is submitted it will take me to the anchor point for that id. The question I have is, how, when i press submit and reload the page, how can I then have that form input as a anchor in the url that will then take me to the place I want to go on the list when the page loads. I can do it manually no problem by adding the hash tag and id to the url myselft it takes me there but It's a pain to do this every time. I would like to use a form. Is this possible? any help appreciated. Thanks
  5. Thanks jcbones, that's cleared it up, how strange.
  6. I found a listing that gets the right answer... $date1 = new DateTime("2009-10-11"); $date2 = new DateTime("2009-10-13"); $interval = $date1->diff($date2); echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days "; I'm not sure how 'm' gives the months remaining after the years have been calculated and 'd' also knows the remainder of days after months have been accounted for but it works that's the main thing. I'm wondering if the original listing didn't work because I am on a windows machine.
  7. I'm on 5.3 as well, makes no sense.
  8. I copied and pasted the code below from php manual, http://www.php.net/manual/en/datetime.diff.php, I should have got the result of '2' as they did but I got the result of '6015'. I can't think why this would be. Any help appreciated. $datetime1 = new DateTime('2009-10-11'); $datetime2 = new DateTime('2009-10-13'); $interval = $datetime1->diff($datetime2); echo $interval->format('%R%a days');
×
×
  • 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.