Jump to content

jeffman

Members
  • Posts

    7,761
  • Joined

  • Last visited

Posts posted by jeffman

  1. try to var_dump($_POST) and see what data the script actually receives. Note that expressions like $userName; don't do anything. The error you're getting on 14 probably means $userName isn't set to anything. If it should have a default value, assign it something

  2. 1. It's wasteful to store so much data as strings of HTML. All you really need to store is an array of URLs. Or, if you want to preload the images, an array of image objects. 2. It's wasteful to replace an entire HTML element just to change an image. Normally, you'd have one permanent image element, and to change the image, you'd update the src attribute. Don't even set the width and height properties; they will take care of themselves. 3. The media array passed to rotator() is weird. It doesn't need to be an array of objects. It can just be an array of strings. 4. I always cringe when I see document.write(). Tutorial writers use it to simplify things, but it encourages bad habits.

  3. I'm really not sure what the relationship is supposed to be between the + and - symbols and the checkbox. I will say that all this looks needlessly complicated. 1. What is the anchor doing there? If you just want :hover behavior, use CSS to put a hover effect on something else. I'm thinking of the <p> I mention in #3 below. 2. What are the divs doing there? If they exist as containers that can appear and disappear, they are extra. The stuff inside them can be made to do that. 3. But you don't need that. You don't need two elements. You need one element. A simple <p> would do everything you are now doing with on link, two divs, and 2 labels. Change the <p> innerHTML from [+] to [-] each time it is clicked. Add a click event listener that checks the innerHTML of the element and do one set of behaviors if the value is [+] and another set if the value is [-]. 4. You do not need a label. The click event listener on the <p> can update the checkbox too.

  4. At first I assumed the absence of quote marks around the name and id attributes in your form tag might be the problem. Some browsers are very strict. But that doesn't seem to be the problem, in FF or Safari. I copied your code, and added another radio button and a submit button. The radio buttons worked as they should, and the form submits.

    poll1.action = "polls_p.php";

    The reference to poll1 is old-fashioned, but Safari seems to honor it. What I don't see is a way your form is connected to poll1submit. What exactly "doesn't work"?

  5. Can I just say that I really hate this code?

    function rotator(options) {    // extract the number of milliseconds each image will be displayed    var a = options.delay;        // extract the array of image objects    var b = options.media;        // create an empty array    var mediaArr = [];    // loop through the array of image objects    for(var i = 0, j = b.length; i < j; i++) {            // extract the HTML for each image and push it into the mediaArr array        mediaArr.push(b[i].img);    }    // create an empty div element    document.write('<div id="rotatorContainer"></div>');        // get a reference to that div    var container = document.getElementById('rotatorContainer');        // create a counting variable initialized to 0    var Start = 0;    // call the rotatorCore function defined below    rotatorCore();    // define the rotatorCore function    function rotatorCore() {            // increase the value of the counter by 1        // this counter will be used to "walk through" the array of images        // note that start retains its value whenever the function is called because        // it "exists" in the parent scope of this function.        Start = Start + 1;        // if the value of the counter exceeds the number of images in mediaArr ...        if(Start >= mediaArr.length)                    // reset the counter to 0; this lets the images rotate forever            Start = 0;                // set the inner HTML of the container div to the text of the next element in        // the mediaArr array        container.innerHTML = mediaArr[Start];                // call this function again after a number of milliseconds        setTimeout(rotatorCore, a);    }}// call the rotator function defined above// pass it an object containing two pieces of informationrotator(    // create an object    {        // the first property of the object is the time each image will be displayed        delay : 2500,                // the second property of the object is an array of objects        media : [                    // create an object            {                // the first property of the object is a string                // the string is HTML that can be used to create an image element                img : '<img src="satan.jpg" width="128" height="128" border="0" />'            }            // if desired, add as many image objects as you want to rotate            // be sure to separate them with commas                // close the media array        ]    // close the object that gets passed to rotator    });

    • Like 1
  6. That's the thing. I don't know what code you're using to "show" the dates, so I have no idea what to tell you. As a rule, people get better results here if they post the relevant code they are confused about. We probably don't need to see your whole script, just the part with the problem you need to solve.

  7. The basic idea looks like this:

    if ($event->StartDate == $event->EndDate){   // do something;}

    I do not know what you mean by "show"

  8. FWIW, my own strategy would be to set the value of onclick to the inner function to begin with, and make the counter a property of 'button.' You'd reference it as this.count. As with any object available in the global space, that's a good idea only if you're sure there won't be an identifier collision.

  9. It's defining an anonymous function and executing it immediately, so that everything inside runs in a new scope. There aren't any conflicts with any other variables.
    In other words, there are two functions here. Think of one as the outer function; think of the other as the inner function. The typical way of assigning an event listener would set the value of onlick to a basic function that has no inner function. Here, by executing the outer function immediately, and setting its return value to the inner function, the value of onclick becomes the inner function. In addition, a "static" variable called 'count' gets created along with it; 'count' is not visible in any other scope. The trick with 'count' is the whole reason for assigning the function this way. It saves you from creating a global variable that might get accidentally overwritten. A good trick for third-party libraries.
  10. Try using rgba color for your background instead of opacity. EDIT: Note that a lot of elements have a transparent background by default, so you may need to give them a background color. Also, I'm not at all sure how this is going to work with your iframe.

  11. 3. Return the value of n * factorial(n - 1). Or, n * factorial(5). So, 6 * 5 which is 30.
    That's your misunderstanding. factorial(5) is the last value returned, not the first. That is because factorial(5) calls factorial(4), which calls factorial(3), and so on. The smallest numbers get multiplied first and work their way backward to 6. That's the tricky thing about recursion.
  12. You will find it very instructive to print or alert the value of history at the beginning of the find function. Notice what happens when the value of start exceeds the value of goal. What you will find is that your suspicions are correct, but that you have not followed them to their conclusion.

  13. If your HTML looks something like this:

    <li><span>Fish </span><span>usd2</span></li><li><span>Dog </span><span>usd4</span></li><li><span>Whale </span><span>usd3</span></li><li><span>Bee </span><span>usd5</span></li><li><span>Chicken </span><span>usd1</span></li>

    then your sorting function can look like this:

    $('#test').click(function(){    li.sortElements(function(a, {;        return $(a.childNodes[1]).text() > $(b.childNodes[1]).text() ? 1 : -1;    });});

    • Like 1
  14. A major part of this will be finding the ideal structure for your XML documents before you convert everything to XML. That means learning what XML can do for you, and the various ways you can manipulate and search XML documents. If you plan to use PHP on your server, you'll need to learn the ins and outs of the DOMDocument object. XPath is also a good tool for searching. So my first advice is to just mess around with a variety of test documents until you're very comfortable with all this. As you learn more, ideas will probably just pop into your head.

  15. In the browser, view the source code. Where the included material should be, do you see: 1. nothing? Your path to the file is probably incorrect. 2. the <?php ?> tags? PHP is not enabled on your server, OR your shell document has an .html extension, and the server is configured only to parse PHP in files with a .php extension. FWIW, the include file does not need <html> and <body> tags, since the shell document already has them.

×
×
  • Create New...