Jump to content

Telemachus

Members
  • Posts

    39
  • Joined

  • Last visited

    Never

Everything posted by Telemachus

  1. I'm using this in script tags the head and I get no problems: [code]arr = new Array( ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"], ["Link name google","http://www.google.com"], ["Link name yahoo","http://www.yahoo.com"], ["Link name msn","http://www.msn.com"] ); function changelink(){ document.getElementById("url").href = arr[new Date().getSeconds()][1];  document.getElementById("url").innerHTML = arr[new Date().getSeconds()][0];  setTimeout('changelink()',1000); }[/code] And this inside the body: [code]<a href="#" id="url"></a> [/code] It works just fine for me in several browsers so personally I have no idea what else to say.  ???
  2. Through the magic of copying and pasting twenty times I have it ticking away right now, but being half asleep as usual I forgot to to remove the comma at the end of the array lol and that little typo took me about twenty minutes to figure out.  I'm betting it's something similar that's the only problem now.
  3. <div style="display: block;" id="yourDiv"> perhaps?  Or if you want it to start off at none (totally invisible), <div style="display: none;" id="yourDiv">
  4. Either use var arr = new Array(["Link name one","ht[i][/i]tp://www.google.com"]); or var arr = [["Link name two,"ht[i][/i]tp://www.google.com"]]; rather than the syntax you just posted.
  5. I realize there's no JavaScript loop so I'm taking it in a more figurative sense.    ;) (Edit: D'oh now I see what you mean fenway, what in the world is wrong with me lol)
  6. If they are leaving a big space did you try the display property yet, rather than visibility?
  7. Ah, okay, so you're looking to do something like this: [code] function change(bottomimg) { document.all ? document.all["featuredimage"].src = document.all[bottomimg].src : document.featuredimage.src = document[bottomimg].src; } [/code] I'd be surprised if the more experienced people don't have a better or more proper way to do it, but sorry, that is all I have.
  8. What I notice is that you're passing bottomimg to the function but then using document.bottomimg.
  9. If you just accessed document.getElementsByTagName("div")[0].childNodes and looked for text nodes, there would be two, "This chicken tastes " and " good."  document.getElementsByTagName("div")[0].childNodes[1].firstChild.nodeValue would be "really" so there are actually three text nodes inside of the div.
  10. Well you can't actually name the variable true or false, but if you have two radio buttons with the same name but unique ids, say true and false, you can just assign it like [code]var isTrue = document.getElementById("true").checked;[/code] you could also validate it easily [code]var isFalse = document.getElementById("false").checked; if (!isTrue && !isFalse){ alert("Please choose true or false."); return false; }[/code] ( document.myFormName.myRadioName[0] and document.myFormName.myRadioName[1] would probably actually be compatible with more browsers, but it's just an example. ) Using it in the PHP coding is exactly the type of thing I need to learn, so I can't be any help there.
  11. This is what I tested and it worked: [code]<span onclick="var doYou = confirm('Do you really want to go?'); if (doYou) self.location.href = 'http://google.co.uk';">Test</span>[/code] I take it that's basically what you're trying to do.  This is just a guess but it almost seems to me like where script is getting confused is in what to do with the true/false; return it as a variable, or return it on the event.
  12. Well I only tinker with it a bit as a hobby myself, but this is what I came up with: [code] function hasChosen(){ var madeChoice; var radio = document.myForm.myRadio; for (s = 0; s < radio.length; s++){ if (radio[s].checked){ madeChoice = true; break; } } if (!madeChoice){ alert("You forgot to pick one"); return false; } else{ return true; } } [/code] For a form something like this: [code] <form action="whatever.php" method="get" name="myForm" onsubmit="return hasChosen()"> <input type="radio" name="myRadio" id="one" value="1" /><label for="one">1</label> <br /> <input type="radio" name="myRadio" id="two" value="2" /><label for="two">2</label> <br /> <input type="radio" name="myRadio" id="three" value="3" /><label for="three">3</label> <br /> <input type="submit" value="Submit"> </form> [/code]
  13. You can loop through them and check if document.myForm.myRadioButton[[i][/i]i].checked is true, and if so set a variable as true and break the loop, and if that variable is false afterwards give the alert, or add to the existing one.
  14. Sounds to me like what you really want is setInterval rather than setTimeout, since the latter will only run once.  Also, assuming that's the same order you have the array in the actual script [code] document.getElementById("url").href = arr[new Date().getSeconds()][1];  document.getElementById("url").innerHTML = arr[new Date().getSeconds()][0]; [/code] should give you the right items.  new Date().getSeconds()-1 and 2 is going to kill everything with an error at 0 and 1 seconds. Hope that's what you need, I'm new here since I'm finally just starting to attempt learning some PHP, but I think I'm alright at the client-side stuff.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.