Jump to content

Ingolme

Moderator
  • Posts

    14,901
  • Joined

  • Last visited

  • Days Won

    177

Everything posted by Ingolme

  1. All you need to understand is the foundations of programming: Variables Operators Data types Data structures (objects, arrays) Conditions Loops Functions In other words, just learn what's in the W3Schools Javascript tutorial. Don't just memorize the code, understand how it works.
  2. That e.preventDefault line wouldn't do anything because you forgot to call the function uses parentheses (). In order for it to work it would have to be e.preventDefault()
  3. There's HTML and then there's CSS. You should read the W3Schools tutorials to see where on the page each one goes. If you want the image to be part of the content of the page, something that the user is meant to look at, then you use an <img> tag. If the image is just there for decoration and the page wouldn't lose its meaning without it, then you use the CSS background-image property. In HTML, the width and height attributes do not have units, so width="500px" is incorrect, it should be width="500". In CSS all values must specify what units are being used, so width: 10; is incorrect and it should be width: 10px; or width: 10em; or width: 10%; The width and height HTML attributes are used to tell the browser to reserve space for the image while the image is loading. You should use CSS for more precise control over the size of the image.
  4. If I could see the actual page, perhaps I could figure out what's causing it to change.There are many things I can't determine from just a picture. Is the text blue or is it just not there? Are the letters wrapped in an element? Are there any errors in the Javascript console? I think it's likely that some Javascript code is doing it.
  5. A different data structure would be needed. Something like this, for example: var game = [ { name: "Dominoes", score: 95 }, { name: "Cards", score: 22 }, { name: "Chess", score: 65 }]; Then you could use the sort() method and pass in a function that compares the scores of each item.
  6. That means you don't understand the box model. Here's an explanation: http://www.w3schools.com/css/css_boxmodel.asp You can change the way the box model works using the box-sizing property, it's supported in Internet Explorer 9 and above. If you need to support Internet Explorer 8 you will have to use the classic box model.
  7. I said that the example page you showed me was done in Javascript. I also suggested CSS. You can't improve the quality of a small image, you need to find the source where the small image came from.
  8. Something like this: $sentence = 'Hello, world!';for($i = 10; $i <= 100; $i++) { echo "<span style="font-size: {$i}px">$sentence</span><br>";}
  9. It looks like if one of those ad scripts that highlights words and turns them into links failed.
  10. You have a function scramble(). It has a parameter "word", except that in the very first line of the function, you're overwriting that parameter so it's useless. Then you're calling the function, but not doing anything with its return value. This would probably improve your code a bit, but it still has problems: document.getElementById("inputValue").innerHTML = scramble(); Also, Javascript is case sensitive, this is a problem: document.getElementById("UserInput") <input type="text" id="userInput" >
  11. You could have a single function for both events: $('.article-previous').click(articleButton);$('.article-next').click(articleButton);function articleButton(e) { var inner = $('.interaction-tab .inner'); var article = $('.interaction-tab .inner article'); var total_width = inner.width(); var slide_width = article.width(); var max_pos = total_width - slide_width; var element = $(this); if(element.hasClass('article-previous') && inner.position().left < 0) { inner.css({ 'left' : '+=' + slide_width + 'px' }); } if(element.hasClass('article-next') && -inner.position().left < max_pos) { inner.css({ 'left' : '-=' + slide_width + 'px' }); } e.stopPropagation();}
  12. It's in the Javascript tutorial in the HTML DOM section: http://www.w3schools.com/js/js_htmldom.asp That explains how to access elements on the page so that you can change them with Javascript.
  13. It's complicated. If you don't have a good understanding of Javascript you're not going to be able to do it. Javascript is put anywhere on your page between <script> tags. The code runs as the page is loading, so if you put it before the HTML element you want to modify then the element won't be accessible, so scripts are generally put at the bottom of the page. What you need to do is access the element using DOM methods such as getElementById() or getElementsByTagName() and assign the event handler. Here are examples of accessing elements in the DOM: var element = document.getElementById("elementID");var listOfElements = document.getElementsByTagName("img");for(var i = 0; i < listOfElements.length; i++) { element = listOfElements[i]; // Do something with element here} There are multiple ways to assign event handlers such as: element.addEventListener("mouseover", doSomething, false);element.onmouseover = doSomething;<img onmouseover="doSomething(this);">
  14. They've done that with Javascript using mouseover and mouseout events. If you don't know Javascript yet you can read through the W3Schools Javascript tutorial. CSS can also make an expanding animation using the :hover pseudo-class and the transition property. Information about those are in the W3Schools CSS reference.
  15. To write to the console it's console.log(), not document.write.log(). Writing to the console is used to look at the values that your application is using. In order to make use of your function you need to change document.write.log(combi.join("n")); to return combi; To put the results of your function onto the page you need to access an element through the HTML DOM and change its innerHTML property or add new elements to the page using createElement() and appendChild(). You also can break a string into letters just by using the split() method, like this: var array1 = str1.split(""); Here's your code rewritten. Assume we have this element on the page: <ul id="data"></ul> Here's some Javascript code to put the data onto the page: function substrings(str1) { var array1 = str1.split(""); var combi = []; var temp= ""; var slent = Math.pow(2, array1.length); for (var i = 0; i < slent ; i++) { temp = ""; for (var j=0;j<array1.length;j++) { if ((i & Math.pow(2,j))) { temp += array1[j]; } } if (temp !== "") { combi.push(temp); } } return combi;}// Put the data onto the pagevar element = document.getElementById("data");var data = substrings("dog");var item;for(vat i = 0; i < data.length; i++) { item = document.createElement("li"); item.innerHTML = data[i]; element.appendChild(item);}
  16. Software in general is a grey area in copyright law. Your application as a whole is protected by copyright (if it is complex and unique enough), but bits and pieces of it are not. If somebody thinks "how do I make my buttons do this effect?" and decides to copy your snippet of code for it, then you most likely can't contest that legally. Also, while they're not allowed to copy your application's entire source code, they are allowed to create another one from scratch that does the same tasks.
  17. What is your code like? The $_SESSION array can as many individual values as you want it to.
  18. I don't think there's a need to invoke jQuery for such a trivial task. For you need to update the HTML <input type='checkbox' id="accept" /> <input type="submit" id="continue" class="btn btn-large btn-info" disabled value="Continuar Compra" alt="Pague com PagSeguro - é rápido, grátis e seguro!" /> Then a short script to make the checkbox change the button document.getElementById("accept").onchange = function() { // The "disabled" state is the opposite of the "checked" state, therefore use the [not] "!" operator document.getElementById("continue").disabled = !this.checked;} It looks like you're using XHTML, you probably should change your site to HTML 5 whenever you have the time
  19. Ingolme

    align form with css

    Display the label as a block. Set the width of the label to 50%. Since the input has a border it needs to be slightly less than 50% in width. Float the label to the left and clear the left side of the label. In order to align the label and input vertically you can set the line-height of the label and its parent element to a fixed value that's the same for both, then set the vertical-align of the input element to "middle"
  20. As long as you don't need to manipulate files and settings on the client's computer, anything can be done on the web. As far as robustness goes, that all depends on how well the application is coded, regardless of the programming language that was used.
  21. Javascript, CSS and HTML cannot be protected since they are sent to the browser so that the browser may interpret it. They are available to anybody who wants to see them. You can't really claim ownership of snippets of code, but if you've built a complete unique Javascript application you can bring it to court if somebody else uses it.
  22. But it isn't necessarily best practice to assign the length to a variable. It is just the most efficient practice. Sometimes you sacrifice efficiency for readability. If it was about efficiency, they would also have a chapter about loop unrolling.
  23. The performance difference is negligible. It's perfectly OK to put the length property in the loop condition if your application isn't time critical, as is the case with all of the Javascript examples on the site. It's easier for beginners to understand if you don't add lines of code that aren't relevant to what's being taught.
  24. If you already have some experience with Javascript, here's a list of events that the <audio> and <video> events fire: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events The "ended" event is probably what you should listen for. If you don't know Javascript yet, you should go through the W3Schools Javascript tutorial.
  25. Javascript can listen for events fired by the video player.
×
×
  • Create New...