Jump to content

davej

Moderator
  • Posts

    3,988
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by davej

  1. <!DOCTYPE html> <html lang="en"> <head> <title>change</title> <script> window.onerror = function(e,p,l){ alert('Javascript Error: '+e+'\nPath: '+p+'\nLine Number: '+l); return true; } </script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#btn1").click(function(){ $("[value=A2]").text("Plane"); }); $("#btn2").click(function(){ $("[value=A2]").text("Bike"); }); }); </script> </head> <body> <h1>Demo</h1> <select id="List"> <option value="A1">Cars</option> <option value="A2">Bike</option> <option value="A3">Train</option> </select> <input type="button" value="Plane" id="btn1"> <input type="button" value="Bike" id="btn2"> </body> </html> --updated 5pm cdt-- fixed ] error mentioned by Dsonesuk below
  2. My code was based on the example on this page... http://www.w3schools.com/howto/howto_js_slideshow.asp
  3. Did you try Dsonesuk's code above? I confused the issue by introducing a different example that used different CSS.
  4. Is this page designed to be usable with Javascript disabled?
  5. Where is iniciarSesion() in the code and where is id="linkLogin" in the HTML?
  6. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>moving block</title> <script> window.onerror = function(a,b,c){ alert('Javascript Error: '+a+'\nPath: '+b+'\nLine: '+c); return true; } </script> <style> *{ margin:0; padding:0; } #container{ position:relative; height:750px; border:5px solid red; } #BlueSquare{ background-color:blue; width: 300px; height: 300px; position:absolute; top:100px; left:100px; } #status{ margin:10px; } </style> </head> <body> <div id="container"> <h3 id="status"></h3> <div id="BlueSquare"> </div> </div> <script> 'use strict'; var blueHeight = 300; var blueWidth = 300; var blueX = 100; var blueY = 100; var phase = 1; var comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; setInterval(squareMatrix, 20); function squareMatrix() { var bs = document.getElementById("BlueSquare"); if (phase == 1){ if(blueWidth > 0) { blueX += 1; blueWidth -= 1; bs.style.width = blueWidth + "px"; bs.style.left = blueX + "px"; }else{ phase = 2; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 2){ if (blueWidth < 300) { blueWidth += 1; bs.style.width = blueWidth + 'px'; }else{ phase = 3; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 3){ if (blueHeight > 0) { blueY += 1; blueHeight -= 1; bs.style.height = blueHeight + "px"; bs.style.top = blueY + "px"; }else{ phase = 4; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 4){ if (blueHeight < 300) { blueHeight += 1; bs.style.height = blueHeight + "px"; }else{ phase = 5; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 5){ if (blueWidth > 0) { blueWidth -= 1; bs.style.width = blueWidth + "px"; }else{ phase = 6; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 6){ if (blueWidth < 300) { blueWidth += 1; blueX -= 1; bs.style.width = blueWidth + "px"; bs.style.left = blueX + "px"; }else{ phase = 7; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 7){ if (blueHeight > 0) { blueHeight -= 1; bs.style.height = blueHeight + "px"; }else{ phase = 8; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } }else if (phase == 8){ if (blueHeight < 300) { blueHeight += 1; blueY -= 1; bs.style.height = blueHeight + "px"; bs.style.top = blueY + "px"; }else{ phase = 1; comment = 'Phase '+phase+' begins with: height:'+blueHeight+', width:'+blueWidth+' x:'+blueX+', y:'+blueY; document.getElementById("status").innerHTML = comment; } } }// end of func </script> </body> </html>
  7. Well, this gets confusing because I don't know what you are using for html. In the slideshow here... http://www.w3schools.com/howto/howto_js_slideshow.asp With the html from the link above -- the following code works both manually and automatic... 'use strict'; var slideIndex = 1; function plusSlides(n) { showSlides(slideIndex += n); } function currentSlide(n) { showSlides(slideIndex = n); } function showSlides(n) { //alert('showslides('+ n +')\nslideIndex='+slideIndex); var i; var slides = document.getElementsByClassName("mySlides"); var dots = document.getElementsByClassName("dot"); if (n==undefined){n = ++slideIndex} if (n > slides.length) {slideIndex = 1} if (n < 1) {slideIndex = slides.length} for (i = 0; i < slides.length; i++) { slides[i].style.display = "none"; } for (i = 0; i < dots.length; i++) { dots[i].className = dots[i].className.replace(" active", ""); } slides[slideIndex-1].style.display = "block"; dots[slideIndex-1].className += " active"; setTimeout(showSlides, 5000); // Change image every 5 seconds }
  8. Try this... function loadFirst(){ var slides = document.getElementsByClassName("mySlides"); var len = slides.length; var loc = window.location.href; var index = loc.indexOf('='); var value = parseInt(loc.substr(index+1)); //alert('value=[' + value + '] len =[' + len + ']'); if (isNaN(value)){ slideIndex = 1; }else if (value>=1 && value<=len){ slideIndex = value; }else{ slideIndex = 1; } //alert('slideIndex = ' + slideIndex); showSlides(slideIndex); }// end of func window.onload = loadFirst;
  9. You could pass different image index values at the end of each link URL. <a href="slideshow.html?index=4">Slide 4</a> var loc = window.location.href; var index = loc.indexOf('='); var value = loc.substr(index+1); alert(value); if (value>=0 && value<slides.length){ slideIndex = value; }else{ slideIndex = 1; }
  10. Oh, I didn't know that. Nice! http://www.w3schools.com/tags/att_input_pattern.asp
  11. For that you'll need Javascript. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"/> <title>title</title> <script> window.onerror = function(a,b,c){ alert('Javascript Error: '+a+'\nFile: '+b+'\nLine: '+c); return true; } </script> <script> 'use strict'; function validateForm(evt){ var txt = document.getElementById('txt1').value.trim(); if (txt.length < 8){ evt.preventDefault(); alert('Submission Aborted\nText is only ' + txt.length + ' characters'); } } window.onload = function(){ document.getElementById('form1').onsubmit = validateForm; } </script> </head> <body> <form id="form1"> <input type="text" name="txt1" id="txt1"/> <input type="submit" value="Submit"/> </form> </body> </html>
  12. Yes, but explain it to us now, so that we will know what you understand.
  13. The above seems pointless to me. What you will more commonly see is the situation below... while (variable = someFunc()) { // truthy value is assigned // use variable }
  14. Unless you are writing Python.
  15. Coding style is meant to make code easy to read and debug. Please post some of this code that doesn't work.
  16. That sounds like drag and drop.... http://www.w3schools.com/HTML/html5_draganddrop.asp
  17. See... https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions https://en.wikipedia.org/wiki/Regular_expression https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx http://www.w3schools.com/jsref/jsref_obj_regexp.asp
  18. $target_dir should be "./uploads/" but that doesn't explain your problem. What is "Strato server" ?
  19. davej

    iframe

    Couldn't an @media query hide the entire thing and unhide a different version?
  20. I think you can do something like this... SELECT t1.activity_job_id AS activity_job_id, t1.activity_time AS open,t2.activity_time AS close, DATEDIFF(t1.activity_time,t2.activity_time) AS elapsed FROM tablename t1, tablename t2 WHERE t1.activity_job_id = t2.activity_job_id AND t1.activity_type = 'Opened' AND t2.activity_type = 'Closed' ORDER BY t1.activity_job_id
  21. Can you write a stored procedure for this? You will have a lot more abilities available in a stored procedure.
  22. Google Analytics? I don't understand your fancy "truthy" conditionals. When is this true? if (window.mouseflow.getSessionId && s.tl && tries > 0 && window.mouseflow.getSessionId !== -1){ Also... setTimeout(function_name_without_parens, delay)
  23. The page contains errors: https://validator.w3.org/nu/?doc=http%3A%2F%2Fabsolutehappinessbook.review%2F
  24. davej

    SQL Understanding

    Use prepared statements and you won't need to worry about it. http://www.w3schools.com/php/php_mysql_prepared_statements.asp
×
×
  • Create New...