Jump to content


  • Posts

  • Joined

  • Last visited

paulclift's Achievements


Newbie (1/7)



  1. I have an autocomplete() function connected to a MYSQL database. The jquery is completely run of the mill: $(function() { $(".choose_venue").autocomplete({ source: "list_venues.php", minLength: 1 }); }); ...and if I manually add a query such as "list_venues.php?term=Ku" onto the URL of list_venues.php, then that page gives a appropriate response (such as the following): [{"name":"Fonderie Kugler"},{"name":"Kulturhaus Helferei"},{"name":"Kunstraum Walcheturm"}]So, a simple `input` such as the following *should* be working: <input type="text" style="width:270px;" class="choose_venue"/> However, the output I get is a window containing no text, but just a number of faint lines. I first thought that this might be something in my CSS, but the problem persists even when ALL css modifications have been removed. My next thought was that it might be a browser issue (I use Safari), but Chrome behaves exactly the same way. The only other idea I had was that the jquery files I was calling were out of date or that there was some other problem, but I tried multiple links and I always get the same result. As of my most recent attempts I am linking to the following files: <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> It appears that the number of these grey lines corresponds to the number of text values that should be returned. But beyond that, I have no idea what is causing this.
  2. @justsomeguy Thanks for your response. I am not particularly knowledgable with JS .... could you describe your solution in a little more detail please?
  3. I am displaying data from one page in another page in the following way: <script> $(document).ready(function(){ $( "#2017" ).load( "data.html .2017" ); $( "#2016" ).load( "data.html .2016" ); }); </script> <div id="2017"></div> <div id="2016"></div> ...BUT I also need to be able to hide (onload) certain div classes from within the linked file... <script> $(document).ready(function(){ $('.private-files').hide(); }); </script> I know that the code above will hide divs by class if they are contained in the main page, but how can I make it so that divs of class 'private-files' in 'data.html' will also be hidden?
  4. Thanks justsomeguy, but this seems to be something which is in development and does not quite suit my needs in this specific case..
  5. Hey all, I have a language switch on a website which updates the displayed language in the main iframe. However, I am also using fancy box, which pops up out of the iframe, and is therefore an iframe within an iframe. I change the language to be displayed with the following code: function setlang(lang) { var i; var len; var list; var ifr = document.getElementById('mainframe'); var cw = (ifr.contentWindow || ifr.contentDocument); list = cw.document.getElementsByClassName('langdiv'); for (i=0, len=list.length ; i<len ; i++){ list.style.display = 'none'; } list = cw.document.getElementsByClassName(lang); for (i=0, len=list.length ; i<len ; i++){ list.style.display = 'inline-block'; } } .....and here is the HTML: <input id="EN" name="view" type="radio" onclick="setlang('EN'); sessionStorage.setItem('language', 'EN');"> <input id="DE" name="view" type="radio" onclick="setlang('DE'); sessionStorage.setItem('language', 'DE');"> <input id="FR" name="view" type="radio" onclick="setlang('FR'); sessionStorage.setItem('language', 'FR');"> Could someone please help me make this work whereby the iframe is not necessarily called 'mainframe' but is simply *any* iframe that has multiple languages? I suspect that this will necessitate converting most of my vars into arrays, something which I am not really confident about doing on my own. Thanks! The website in question is: www.neuverband.ch
  6. I was wondering if someone could come up with a way of using the current date to set the position of a div. I would like to apply such a process to this page: http://www.paulclift.net/news.html The object in question which I would like to move automatically up and down, so that it is in the appropriate place relative to the other items on the page, is the three HR lines with past/future written above & below it. There must be a way to do this - not having to constantly move this object, and others like it on other pages, would be a huge time-saver! Please help if you have any ideas. Thanks. Here is the code I have so far: //first, get today's date Date.prototype.yyyymmdd = function() { var yyyy = this.getFullYear().toString(); var mm = (this.getMonth()+1).toString(); // getMonth() is zero-based var dd = this.getDate().toString(); return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]); }; d = new Date();//next, set the 'seperator' id to today's date document.getElementById("seperator").setAttribute("id", d.yyyymmdd());//next, find divs with a date for an ID function sortDivs(div) { var elems = document.getElementsByClassName("date");// Sort array numerically elems.sort(function(a, b) { return a.id.split()[1] - b.id.split()[1]; });// finally, move elements to sorted order while (iLen--) div.insertBefore(a[iLen], div.firstChild); } <div id="news-content"></div><div id="separator" class="date">THIS IS MY SEPARATOR DIV/div><div id="20150523" class="date">CONTENT<div>MORE CONTENT</div></div><div id="20150524" class="date">CONTENT<div>MORE CONTENT</div></div><div id="20150525" class="date">CONTENT<div>MORE CONTENT</div></div>
  7. Just realised I never thanked you for this, justsomeguy - so thanks very much - your code really helped me out a lot!
  8. AHHHH yes, the '.' before 'contentWindow' ..... now we're in business
  9. I think perhaps that it would be better just to switch to an 'if' and 'else' .... your thoughts?
  10. With this code: <script> function setlanguage(language, n1, n2, n3) { var ShowLang = document.getElementById('mainframe').contentWindow.document.getElementsByClassName(language); for(var i = 0; i < ShowLang.length; i++) { ShowLang.style.display='none'; } var HideLang = document.getElementById('mainframe')contentWindow.document.getElementsByClassName(n1); for(var i = 0; i < HideLang.length; i++) { HideLang.style.display='none'; } } </script> ...I get the error message "SyntaxError: Expected an identifier but found 'contentWindow' instead" for the line: var HideLang = document.getElementById('mainframe')contentWindow.document.getElementsByClassName(n1);
  11. hmmm it seems that having two 'for's or two 'var's in my function is causing the problem...... I thought that that was okay?
  12. Thanks for the help...... that's good for a start, but I noticed that if I replace 'n1' with, for example 'IT', those divs still don't disappear from the page loaded inside the iframe..... I cannot understand why that part is not working!
  13. I noticed that other people seemed to have gotten the above javascript running with a 'getElementById' rather than by ClassName....... but surely that would not stop it from working.... Also, I know that an 'if' and 'else' inside the function would be rather more elegant....
  14. So the following seems promising, but is not working for me for the moment: <script> function setlanguage(language, n1, n2, n3) { var ShowLang = document.getElementById('iframe').contentWindow.document.getElementsByClassName(language); for(var i = 0; i < ShowLang.length; i++) { ShowLang.style.display="block"; } var HideLang = document.getElementById('iframe')contentWindow.document.getElementsByClassName(n1, n2, n3); for(var i = 0; i < HideLang.length; i++) { HideLang.style.display="none"; } } </script> <body> <input id="english" type="radio" checked onclick="setlanguage('EN', 'DE', 'FR', 'IT')"> <input id="deutsch" type="radio" onclick="setlanguage('DE', 'EN', 'FR', 'IT')"> <input id="francais" type="radio" onclick="setlanguage('FR', 'EN, 'DE', 'IT')"> <input id="italiano" type="radio" onclick="setlanguage('IT', 'EN', 'DE', 'FR')"> <div id="iframe"> <iframe src="home.html"></iframe> </div> </body> (it goes without saying that the "home.html" document is full of divs with class "EN", "DE" etc....) Perhaps I need to reload the iframe page after changing the display value in the parent document?
  15. Hmmm is that right? I was looking for other instances of this and got the impression that it was possible..... my other thought was to use sessionStorage and pass the value to the iframe documents, but if you could simply control the iframe pages from the index.html it would be much cleaner....
  • Create New...