Jump to content

GoDxNero

Members
  • Content Count

    27
  • Joined

  • Last visited

Community Reputation

0 Neutral

About GoDxNero

  • Rank
    Newbie
  1. Thanks for your help, this is what I got now. And it seems to workJavascripts function initRanks(){var ranks = document.getElementsByClassName("rank");for(var i = 0; i < ranks.length; i++){ranks[i].innerHTML = i+1;}} Body <table><tr><td class="rank"></td><td></td></tr><tr><td class="rank"></td><td></td></tr><tr><td class="rank"></td><td></td></tr></table>
  2. <html><body><script type="text/javascript">for (i = 1; i <= 3; i++){document.getElementById('rank').innerHTML=+i;}</script><table border="1"><tr><td id="rank"></td><td>name</td></tr><tr><td id="rank"></td><td>name</td></tr><tr><td id="rank"></td><td>name</td></tr></table></body></html>
  3. In this code. The results boxes background are supposed to turn blue or red and alerts when all of the results are 15. This works with fire fox and ie8 but not on ie7 . Can anyone please help me decode this so that it work with ie7? Thanks alots in advance function id(name){/* this is just a shortcut to make the actual code shorter. */return document.getElementById(name)} function val(name){/* another shortcut function */return parseInt(id(name).value)} function updateValues(){id('r1').innerHTML = val('x1') + val('y2') + val('z3');id('r2').innerHTML = val('x1') + val('y1') + val('z1');id('r3').innerHTML = val('x2') + val('y2') + val('z2');id('r4').innerHTML = val('x3') + val('y3') + val('z3');id('r5').innerHTML = val('x3') + val('y2') + val('z1');id('r6').innerHTML = val('x1') + val('x2') + val('x3');id('r7').innerHTML = val('x1') + val('x2') + val('x3');id('r8').innerHTML = val('y1') + val('y2') + val('y3');id('r9').innerHTML = val('y1') + val('y2') + val('y3');id('r10').innerHTML = val('z1') + val('z2') + val('z3');id('r11').innerHTML = val('z1') + val('z2') + val('z3');id('r12').innerHTML = val('z1') + val('y2') + val('x3');id('r13').innerHTML = val('z1') + val('y1') + val('x1');id('r14').innerHTML = val('z2') + val('y2') + val('x2');id('r15').innerHTML = val('z3') + val('y3') + val('x3');id('r16').innerHTML = val('z3') + val('y2') + val('x1');checkAnswer();}function checkAnswer(){var i;var correct = 0;for(i = 1; i <= 16; ++i){var cell = "r" + i;if(parseInt(id(cell).innerHTML) == 15){id(cell).style.backgroundColor = "#00ff00";++correct;}else{id(cell).style.backgroundColor = "#FFD700";}}if(correct == 16){var used = new Array(1,2,3,4,5,6,7,8,9);for(i = 1; i <= 3; ++i){var idx = used.indexOf(val('x' + i));if(idx == -1) break;used.splice(idx, 1);idx = used.indexOf(val('y' + i));if(idx == -1) break;used.splice(idx, 1);idx = used.indexOf(val('z' + i));if(idx == -1) break;used.splice(idx, 1);}if(used.length != 0){for(i = 1; i <= 16; ++i)id("r" + i).style.backgroundColor = "#ff0000";alert("Jij hebt dezelfde cijfer meer dan 1 keer gebruikt.");}else{for(i = 1; i <= 16; ++i)id("r" + i).style.backgroundColor = "#0000ff";alert("Gefeliciteer , jij hebt het juist antwoord gevonden !");}}} <body class="home" onload="updateValues()"><form><table id="rs1"><tr><td id="r1"></td><td id="r2"></td><td id="r3"></td><td id="r4"></td><td id="r5"></td></tr><tr><td id="r6"></td><td><select onchange="updateValues()" id="x1"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="x2"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="x3"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td id="r7"></td></tr><tr><td id="r8"></td><td><select onchange="updateValues()" id="y1"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="y2"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="y3"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td id="r9"></td></tr><tr><td id="r10"></td><td><select onchange="updateValues()" id="z1"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="z2"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td><select onchange="updateValues()" id="z3"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option></select></td><td id="r11"></td></tr><tr><td id="r12"></td><td id="r13"></td><td id="r14"></td><td id="r15"></td><td id="r16"></td></tr></table><br /><button type="reset" onclick="setTimeout('updateValues()', 10)">Reset</button></form><br />
  4. But if I put both the contents and the image together in one div it it wont stack >< . Or you mean make div z-index=2 and image z-index=1 ?
  5. Is there a known way to change background width or height ? I want to make a function which detects screen resolution and put them in a variable, then use that variable to change the width and height of my background . Is that possible too ? the body background I mean. Well I think this can be solved if I put another big div to wrap the entire page together and put my main background here, then I can change the width and height of the image I guess. But its not so handy ><. Wanna see if change body background width and height possible first : )
  6. I have seen those command screen.width on javascripts somewhere . Are they useless ?
  7. Well it was a code from Deidre'dad . It contains a function for setCookie and a function for checkCookie. He said it will work but I tried alots and nothings much happend : ( . Do I really need to implant a getCookie function ? if not what is wrong with the code above ?
  8. Yes you got it right away . 100% based on screen resolution and not on browser size . is it possible ?
  9. Do I need "getCookie" too ? I though there are always setCookie , getCookie and checkCookie right ? Please explain me ... I cant find anything more information on w3school .
  10. I have seen how to change background to always 100% depends on your browser size. But its really annoying because it change all the time when you change the size of your browser . So is there a way for background to always be 100% depends on your sreen resolution setting and not the size of your browser? So if I got a background of 1280x960 and a screen resolution of 800x600 the background image will become 800x600. But since it not depend on browser height and width the "100%" command prolly not work. Can I solve this probleem somehow with javascripts ? Like "get screen resolution setting" and "change image-background to it" ?
  11. Srry I am such a newbie ... tried countless time but cant seem to be able to solve the probleem on my own. Checked many forums on google but haven't found any answer . Please give me few hints how to solve it
  12. Well I am currently using this java script: function toggle(element) {if (document.getElementById(element).style.display == "none") { document.getElementById(element).style.display = "block"; } else { document.getElementById(element).style.display = "none"; }} How can I make it so that when I start a new function toggle, the previous ones get reset back to invis ? What I mean is that if I got 2+ div ( all vision = invisible ) . Once I click on the first button the first div will appear and when I click the second button the second div will appear together with the first and just like that with the third div and so on... But I want so that once I click the other button it will be the only one that show up and the rest which vision=visible turn back to invisible. Do you guys know a methods work with alots div this way ? Thanks alots in advance !
  13. Btw i just found a good exemplaar so I copied and edit it abit. But a part is not working : <html><head><script>var expDays = 365;var exp = new Date(); var favImage = "";exp.setTime(exp.getTime() + (expDays*24*60*60*1000));function saveImage(form){ var favImage = form.favSelect.value; if ( favImage == "" ) return; SetCookie('image', favImage, exp); getBodyBG( );}function GetCookie(name) { var cookies = document.cookie.split(/; /g); var arg = name + "="; for ( var c = 0; c < cookies.length; ++c ) { var ck = cookies[c]; if ( ck.indexOf(arg) == 0 ) { var temp = ck.split(/=/); return unescape(temp[1]); } } return "";}function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");}function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();}function getBodyBG(){ document.body.style.backgroundImage="url('" + GetCookie("image") + "')";}</script><style>body, #mydiv { background-repeat: repeat-all; }</style></head><body onload="getBodyBG();"><div class="bgs"><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-01.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond01.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-02.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond02.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-03.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond03.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-04.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond04.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-05.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond05.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-06.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond06.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-07.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond07.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-08.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond08.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-09.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond09.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-10.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond10.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-11.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond11.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-12.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond12.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-13.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond13.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-14.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond14.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-15.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond15.jpg)';saveImage(document.body.style.backgroundImage)" /></div><div class="bg"><img id="bg" src="Afbeeldingen/Bg-icon-16.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond16.jpg)';saveImage(document.body.style.backgroundImage)" /></div></div></body></html> I think its not suppose to be like this ... There is the originale : http://www.clearviewarts.com/cookiebgi.htmlI want to active the java on clicking the image instead clicking the button. Anyway this is pretty much a big code >< . Is there a way to make this smaller like yours ? This code below seems to be wrong . saveImage(document.body.style.backgroundImage)
  14. Just tried this but nothings show up . If I understand correctly the " setCookie ("background", "2", 1); " only create a cookie and give it a name right ? So this code " var background = getCookie("background"); " make that the cookie realise which is my current background or just get the cookie by name ? So if my current background name is Achtergrond01.jpg then " var background = getCookie("background");" var background will be Achtergrond01 . But I didnt give any specifiek name to my backgrounds . I only give the url of my background to onclick events :<img id="bg" src="Afbeeldingen/Bg-icon-01.jpg" onclick="document.body.style.backgroundImage='url(Afbeeldingen/Achtergrond01.jpg)'" />Afbeeldingen/Bg-icon-01.jpg is a small model of Afbeeldingen/Achtergrond01.jpg which I used as a small icon to click on . setCookie ("background", "2", 1);function checkCookie() { var background = getCookie("background"); if (background != "") { alert (background); var bg_image = "url(Afbeeldingen/Achtergrond" + background + ".jpg)"; document.body.style.backgroundImage = Afbeeldingen/Achtergrond12.jpg; }}
×
×
  • Create New...