Jump to content

aceuk007

Members
  • Posts

    13
  • Joined

  • Last visited

aceuk007's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. You know I did not ask for you help you did that when you replied to my post. Some people just don't grasp how this all works .I'm 57 and I'm not looking for a career in coding. I just wanted to create this small program. You know it's sad that you wasted half hour of your life just so you can brag how great you are. Am I bothered, not in the least. I will just stick with my not perfect but working code.
  2. dsonesuk - My project is nearly finished. I was just looking to see if there was a shorter way of writing sections.What you are suggesting might be the correct way but seems like I would have to re-write a lot of stuff. The problem with that is Most of the code is what I have picked up on the net and some help like yourself.I have no understanding of coding. So this is not something I would like to do. cheers
  3. Hi Is there a shorter way of writing the following code. (data === "item1" || data === "item2" || data === "item3" || data === "item4") like (data === "item1" to data === "item4") as my list will be over 100 items. Cheers Heres a jsfiddle with the code in it http://jsfiddle.net/8mw1s2zj/6/ Please note this only has to work on IE11 and be jscript. Here is the piece of code var list=document.querySelectorAll("#dragsource li"); for(i=0;i<list.length;i++){ list.draggable=true; list.ondragstart=function(event){ var event=event||window.event; var dt=event.dataTransfer; dt.setData("text", event.target.id); dt.effectAllowed="move"; var data = dt.getData("text"); if((document.getElementById("onoff").value=="On") && (data === "item1" || data === "item2" || data === "item3" || data === "item4")) { (document.getElementById("fruit").style.color = "red") && (document.getElementById("veg").style.color = "black") && (document.getElementById("games").style.color = "black"); } else if((document.getElementById("onoff").value=="On") && (data === "item5" || data === "item6" || data === "item7" || data === "item8")){ (document.getElementById("veg").style.color = "red") && (document.getElementById("fruit").style.color = "black") && (document.getElementById("games").style.color = "black"); } else if((document.getElementById("onoff").value=="On") && (data === "item9" || data === "item10" || data === "item11" || data === "item12")) {(document.getElementById("games").style.color = "red") && (document.getElementById("fruit").style.color = "black") && (document.getElementById("veg").style.color = "black"); } else if((document.getElementById("onoff").value=="Off") && (data === "item1" || data === "item2" || data === "item3" || data === "item4" || data === "item5" || data === "item6" || data === "item7" || data === "item8" || data === "item9" || data === "item10" || data === "item11" || data === "item12")) { (document.getElementById("fruit").style.color = "black") && (document.getElementById("veg").style.color = "black") && (document.getElementById("games").style.color = "black"); } }; }
  4. dsonesuk - Thank you for your help got there in the end. thescientist - thank you for putting in my language ( Basic)
  5. dsonesuk - Thank you for your effort. I will be away for a few days very busy house moving my daughter.Just thought I'd let you know as I did not want you to think I just have not bothered to reply. I have corrected this <ul id="fruit">Fruit </ul> to <ul id="fruit"> <li>Fruit</li> </ul> Also Have done this section ul li:first-child ~ li {display: none !important;} removing(all of them) #veg > * { display: none; } Plus added this ul#dragsource { /*margin: left; what????? */ column-count: 6; column-gap: 20px; column-width: auto; text-align: left; } So what is happening is there is only one item on display to drag into target area. when you drag item into box the next item on list shows. Re 3. I only have to get it working in IE11. I have added the following <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge" > <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://www.addressfinder.co.nz/assets/v2/widget.js"></script> This gives me correct number of items on page but no shuffle or drag & drop. Re 1. Sorry but I can't see a difference between $(document).ready(function() { }); shuffleList(); and what you put $(document).ready(function() { }); shuffleList(); Or should I not include shuffleList(); Once again thanks for you time
  6. dsonesuk - So put it like this $(document).ready(function() { }); shuffleList(); With the correct HTML do you mean I currently have <ul id="dragsource"> <li id="item1" draggable="true">Apple</li> when it should be <li id="dragsource1" draggable="true">Apple</li> Have Got this right One other thing Do you have any idea why these solutions work in fiddle but not when I save as .HTML
  7. dsonesuk - Cheers adding !important; did the trick. but using $(document).ready(function() { }); instead off shuffleList(); stopped D&D , shuffle working..Still everthing is ok now thanks for your help. Nearly at the end off my project. Cheers
  8. dsonesuk - Thanks for reply . I am at work so hope to look over this tonight.Cheers
  9. dsonesuk - I have code in css (see editted #1). Again this worked perfectly before .
  10. john_jack - Thank you for your effort . It just won't work when I save it. I'll have to look for a jscript to do what the jquery bit is doing. It all worked fine until I added the jquery. It has to work on IE11 as this is what we have on the laptop. It was just going to be a training tool to use in the post room.Sub the drop point name for dept and items would be names .dsonesuk - You my not have seen my earlier post but I should explain that I have almost no understanding of this. I have got this far by finding bits of code for what I want to do. I used the jquery as I could not find jscript to do what i wanted. I Checked you jsfiddle Shuffle not working and dropped item still visible when dropped , but thank you for trying
  11. john_jackI have tried it in jsfiddle and works But when I save it as a .html It does not work . I have no D&D or shuffle or number of items on page. Just does not make sense. I'm using IE11 (which is all it has to work in) put all the code on notepad, then save as " file name.html / type all files / encoding UTF-8" and nothing works. Any idea why that is.
  12. Ingolme & john_jack Thank you for replying.. I should explain that I have almost no understanding of this. I have got this far by finding bits of code for what I want to do . Would it be possible for you to show how it should look Cheers
  13. UPDATE - Drag & Drop is working But need dropped item to be invisable. Again this was working, code in css #fruit > * { display: none; } Code done for each box New jsfiddle -jsfiddle.net/eru2mc2k/1/ Hi My first post here so hope I've posted everything correct. My drag & drop was working fine until I added the following code in script. shuffleList(); function shuffleList(){ var origList = $("#dragsource li").detach(); var newList = origList.clone(); for(var i=0; i<newList.length; i++) { var randomIndex = randomInt(newList.length - i); newList[i] = origList.splice(randomIndex, 1); $("#dragsource").append(newList[i]); } } function randomInt(maxNum){ return Math.floor(Math.random()*maxNum); } $(document).ready(function () { var $lis = $("#dragsource li").hide(); $lis.slice(0,20).show(); var size_li = $lis.length; })I The above code shuffles my list and displays 20 items from it ,which I need Can someone please look at this so the drag and drop work again. Thank you. Here's jsfiddle http://jsfiddle.net/W4Km8/8725/
×
×
  • Create New...