Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Posts posted by jeffman

  1. You will find PHP syntax very similar to C and javascript. A number of built-in PHP functions, like strlen and array_push will also seem very familiar. There's a lot to learn, but when you go looking for some basic things, there's probably a version that sounds like what you already know.

     

    PHP is a lot like classic C with OOP support. 3rd party libraries tend to be OO.

     

    The online manual is one of the best development resources of its kind. In contrast, I personally find Microsoft documentation inscrutable.

  2. Alternatively, switch all the CSS and jQuery to element selectors. (Stuff like ul ul.) That way, if you need to add more submenus, you won't need to change the code. Most menus I've seen work that way.

  3. Assuming I've pictured your idea clearly, I would do it like this. I'd want the two images to behave as a unit, so that other content could be placed next to it. So I'd put them both in a div, and limit the dimensions of the div to the exact dimensions of the combined images. Set the display property of the images to block so that one falls below the other, and also so that there is no gap between them. If the images are embedded in <a> elements, they should display as blocks also.

     

    HTML

    <div id="buttons">    <a href="destination1"><img src="flag1.jpg"></a>    <a href="destination2"><img src="flag2.jpg"></a></div>

    CSS

    #buttons {    height: 256px;    width: 128px;}#buttons a {    display: block;}#buttons img {    display: block;}

    If you need to display content to the side of the images, apply the float property.

  4. Remember there are two different kinds of table cells to play with. There is the big table cell on the left in table1. There are also the table cells in table2. With this --

     

    .table2 td {vertical-align: top;}

     

    the content of the cells in table2 lines up no matter how many <p> elements are in each. Changing the vertical-align of .table1 td doesn't affect that. You can tweak other positioning with padding.

  5. Please don't use relative positioning for indentation. Instead, set the margin and padding for all ul and li elements to 0px. Then correct one or the other (usually padding) for specific selectors. The reason is that different browsers create the indentation in different ways. Note that you can also control (in a general way) where how the bullet is positioned.

  6. The easiest thing would be to Google "jQuery slideshow". You'll need to download or link to the newest jQuery library and download a plugin library that interests you. jQuery is not easy to learn, but for a lot of these you don't need to learn very much. The real set up is the way you organize your HTML. Any javascript you need can usually be copy/pasted with few changes right from the plugin's homepage.

     

    That said, a slideshow is a very good project for teaching yourself javascript. If you show us what you've tried so far, we can help out. If you haven't even started, I would suggest learning how to do this: in a fresh document, put a button and an image. Click the button to execute a function that changes the src attribute of the image. That's not your slideshow, but you'll learn some basic skills that you'll need.

  7. It's not quite what you think. Try this:

     

    <!DOCTYPE html><html><head><title>this and event</title><script type="text/javascript">window.onload = function () {alert(out.innerHTML);}</script></head><body><div id="out">Hi</div></body></html>

    I believe that's legacy stuff, and I don't like it at all. :)

  8. Play with this. Notice that you can use the same class names as many times as you want. You don't need special id's.

     

    <!DOCTYPE html><html>    <head>        <style type="text/css">            .slide {                display: none;                background-color: #ccc;                width: 100px;            }        </style>        <script type="text/javascript" src="jquery-1.9.1.min.js"></script>    </head>    <body>        <p class="trig">Slide</p>        <div class="slide">            <div>                <p>stuff</p>                <p>stuff</p>                <p>stuff</p>                <p>stuff</p>            </div>        </div>        <p class="trig">Slide</p>        <div class="slide">            <div>                <p>other stuff</p>                <p>other stuff</p>                <p>other stuff</p>                <p>other stuff</p>            </div>        </div>        <script type="text/javascript">            $(".trig").click(function () {                $(this).next().slideToggle("slow");            });        </script>    </body></html>
  9. As you are using it above, out is simply a global variable. If you use it in a function without also declaring it with the var keyword (as you do in fn1) it will retain the global context. Any changes you make to it in fn1 will affect out globally. If you use the out identifier in a function and do declare it with the var keyword, it is a whole new variable, local to that function, and global out is left alone.

     

    I would not call that forgiving. It is entirely to be expected.

  10. A single var keyword can initialize an arbitrary number of variables as long as they are separated by a comma. At the same time, you can set an initial value for any of them. In this case, only the second variable is being initialized to a value.

  11. This is basically OK. Your goMad() function needs work.

     

    These statements are all fine:

     

    var inputs = document.getElementsByTagName("input");

    // the statements I deleted are not finevar div = document.getElementById("story");div.innerHTML = story;

     

    inputs is a collection, which works like an array. You can loop through it if you like, or you can access the elements directly, using an index, like this: inputs[0]. It looks like you were trying to do that with your words variable, but words is not a collection or an array, so it won't work like that.

     

    The way you tried to build your story variable is almost correct.

     

    A text input does not have a "words" property, so forget about that. You can find the text in the input in its value property, like this: inputs[0].value

     

    That should be all the information you need to fix your function.

     

    (Please do not double-post in the future. :) )

×
×
  • Create New...