JavaScript - Simple Bouncing Menu Advice Needed
I found a menu I really like at the top of the page at www-dot-sachscreative-dot-com but can't figure out how it works from the source code. Can someone tell me how to make something like it which is browser independent and uses javascript and/or CSS? It's been years since I did javascript work and I've forgotten must of what I used to know. Thanks.
Similar TutorialsHi All, I am looking to build a gallery similar to this one: http://www.designguru.co.za/pages/brand.php I am new to MooTools and don't know where to start, which plug ins etc.. Can anyone help me or just point me in the right directions Thanks in advance I'm trying to create an extended version of the famous bouncing ball script in HTML5/JS. This is where balls are drawn using the canvas which then move around the canvas randomly. What I'm trying to achieve is to replace that drawn ball with an actual jpg/png image. Also to have each image to redirect you to different pages when clicked.
Here's some code I wrote. It's just a red ball traveling around the screen. The point is to simulate some rudimentary physics. This means I have to make the ball bounce around the screen, but also get pulled down by gravity a bit. I did the bouncing part. However, I'm not sure how to simulate gravity. Any tips? Basically I just have to reduce the vertical velocity of the ball by a certain amount at every interval, but I'm not sure how to do that. I've tried different for loops in which vy will decrease by one, but to no avail! Code: <html> <head> <style> table {border-collapse:collapse} </style> <script> nx=128; ny=32; wx=600; wy=400; dx=Math.floor(wx/nx); ny=Math.round(nx*600/1000); x1=1;y1=1; vx=1;vy=1; function dart() {id1=x1+","+y1; b1=document.getElementById(id1); b1.style.backgroundColor="yellow"; if(x1==0 || x1==nx-1)vx= -vx; if(y1==0 || y1==ny-1)vy= -vy; x1 = x1+vx; y1 = y1+vy; id1=x1+","+y1; b1=document.getElementById(id1); b1.style.backgroundColor="red" } </script> </head> <body> <table> <script> dy=dx; for(i=0;i<ny;i++) {document.write("<tr>"); for(j=0;j<nx;j++) {color="yellow"; id1=j+","+i; document.write( "<td id="+id1+" style='background-color:"+color+ ";width:"+dx+";height:"+dy+"'></td>"); } document.write("</tr>"); } </script> </table> <form> Number of milliseconds <input type ="text" value="10" id="ms"/input> <br> <input type="button" value="dart" onclick="setInterval('dart()',document.getElementById('ms').value)"/input> </form> </body> </html> CLIFFS: - code shows red dot bouncing around - how do i decrease vertical velocity by N amount at every interval? Spent past few days helping my son for his project of manipulating bouncing ball. Please help me this script work. Once user inputs the new ani value, the ball goes out. I want user to set any value ani, int and size of the ball to achieve desired animation. Seriously urgent... Thanks! <HTML> <HEAD> </HEAD> <BODY> <IMG ID="ball" STYLE="position: absolute; left: 325; top: 200; width: 30; height: 30;" SRC="images/ball1.gif"> <SCRIPT LANGUAGE="JavaScript"> function showAlert() { alert('ANI=' + ani + ', INT=' + int + ', SIZE=' + wxh + ''); } </SCRIPT> <SCRIPT LANGUAGE="JavaScript1.2"> <!-- var myBall = document.getElementById("ball"); var loc = 200; var ani = 10; var direction = 0; var int = 50; var wxh = 30; setInterval("myFunction()", int); function myFunction(){ if(0 == direction) { /* move down */ loc += ani; if(loc >= 500) { /* reached lower limit, change direction */ direction = 1; } } else { /* move up */ loc -= ani; if(loc < 10) { /* reached upper limit, change direction */ direction = 0; } } myBall.style.top = loc; } // --> </SCRIPT> <SCRIPT LANGUAGE="JavaScript1.2"> function readText (form) { if(form.f_ani.value != ""){ ani = form.f_ani.value ; myBall = document.getElementById("ball"); loc = 200; direction = 0; int = 50; setInterval("myFunction()", int); myFunction(); } showAlert(); } </SCRIPT> <FORM action="" method="Get"> Ball Movement (10 pixels):<input type='text' NAME="f_ani" value="10" size="20"><br> Interval (200 milliseconds):<INPUT type="text" id="f_int" value="200" size="20" name="1"><br> Ball Size (10 pixels W&H):<INPUT type="text" id="f_size" value="30" size="20" name="2"><br> <input type='button' value='Send' onclick="readText(this.form)"> <INPUT type="reset"> </FORM> </BODY> </HTML> I have a page with options, and I need to hide options unless a certain choice is selected. So say you have a select box for male and female, if they select male, I need it to show male options, and if they select female, it shows female options. How can I hide things until selected and then show the textboxes and stuff? Thank you! in excel i want to replace the word bebo with a value in cell B1 this is the line CREATE TABLE IF NOT EXISTS `bebo` ( `id` int(10) NOT NULL auto_increment,`beboid` varchar(255) default '0',`status` varchar(255) default 'No Comment Posted',PRIMARY KEY (`id`)) in column B i have a load of values so i need an excel formula to replace bebo so that it will take values from B1 to B26 any ideas please? I know this is not the correct section to be posting in but couldnt find a relative section on this site.. Thanks for your help Hi Coders... I'm building a 'really simple' JavaScript program to help editors write SEO-friendly META titles and META descriptions. The idea is you have 3 text boxes, each on a separate line: BOX 1 - META TITLE [ i.e. "Cool website page" ] BOX 2 - FILE NAME [ i.e. "This is a really cool web page about cool stuff"] BOX 3 - META DESCRIPTION [ i.e. "cool-web-page" ] As the editor types in the boxes, a serp listing is displayed as it would appear on Google (and ideally how it would appear on Bing and Yahoo): Cool website page www.coolwebsite.com/cool-web-page This is a really cool web page about cool stuff Kudos to any one who could point a JavaScript newbie in the right direction I'm in search for a simple and clean timed rotation script. I have these quotes, and right now they're coded so that a single quote displays and changes upon refresh. The script is really clean, and I would like to maintain the cleanliness but make the images rotate every couple of seconds. Here's the script... Code: <script type="text/javascript"> quote = new Array(3); quote[0] = "Quote 1"; quote[1] = "Quote 2"; quote[2] = "Quote 3"; index = Math.floor(Math.random() * quote.length); document.write(quote[index]); </script> It's probably a really simple piece of coding, but I'm still new to JavaScript, so it's obviously out of my range. I appreciate anyone who will help I'm looking to find a script... My client wants his users to be able to enter their zip code into a "check coverage area" text box. Then, on submit, it should return a message saying whether zip code is covered by his business. It seems like this would be a simple (ish) "if-else" script, listing the covered zip codes, but I'm not very experienced in javascript. Can anyone direct me to a free or cheap script that I could use and adapt for this? Thanks soooo much. Not new to programming but I am to JQuery (and j/script in general). I need to query a mysql database to return a small amount of data (some text) based on a user code (e.g. MrABC). I could use an iFrame and PHP but if the internet connection is down I do not want error messages displayed - the intended audience have limited cognitive capabilities and will not cope with ERROR 404 etc... Essentially I need to be able to create a function that can be called with a parameter of the usercode and which returns the text from the lookup. What I put in the function is a complete mystery to me ... Hello all, As I am new to java scripts, I usually solve thing with trial and error. What I need is a very simple java script for a count down timer, after searching here I found this: ---------------------- Code: <font style="font-size:72px" color="#FF0000" face="Arial"> <script type = "text/javascript"> var page = "http://www.google.com"; //The page to redirect to function getSeconds() { startTimer (3); // 36 hours } var timeInSecs; var ticker; function startTimer(secs){ timeInSecs = parseInt(secs); ticker = setInterval("tick()",1000); tick(); // to start counter display right away } function tick() { var secs = timeInSecs; if (secs>0) { timeInSecs--; } else { window.location = page; // stop counting at zero // and start again if required } var hours= Math.floor(secs/3600); secs %= 3600; var mins = Math.floor(secs/60); secs %= 60; var result = ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; document.getElementById("countdown").innerHTML = result; } </script> <body onload = "getSeconds()"> <span id="countdown" style="font-weight: bold;" ></span> ----------------------------- I modified some stuff, as I defined the font face and size, the color as well, and I added a var to open a certain page when the time is over (as I said before, all these modifications came right with trial and error). So, is that script good? or are there better scripts that do the same job? And, can someone please provide me with a script that does the same functionality of the script I mentioned but instead of showing digits it shows: 01 minutes 31 seconds ? Thank you so much. See below:
Hey everyone! This is my first post, so let me go ahead and say hey to everyone at the forums. I myself don't know a whole lot about programming/coding, but I do run my business completely off the internet so I'm not clueless. I have a firm grip on HTML, and I can edit CSS files usually whenever I need to. All my sites use Wordpress now anyway, so there's rarely any need to check or edit the code. Anyways, to my dilemma. I basically have an old website of my own (http://www.knowtheirbackground.blogspot.com). It's a pretty old site I hosted on Blogger, and if anyone is familiar with Blogger it's pretty simple. I downloaded that theme from a site and since all Blogger themes are XML I never really looked at the code. Basically, I want to have a menu like you see on the right of the site I linked you to. A tabbed javascript menu (from what I looked at of the code recently I thought the menu was pretty much made using javascript and css). I've tried Googling and Bing-ing and yahoo-ing tutorials to make a tabbed menu and haven't been successful yet. I want one that operates just like the one on Know Their Background, only things I would change is the text and maybe the colors. I've looked and tried for days and have been unsuccessful. Any help I would GREATLY appreciate. P.S. I also tried using jQuery or something along those lines and nothing. Tried some wordpress plug ins too but they only work in widgets when they do work.. I want my menu in a sticky post on the front page. Hello, I have a specific need in javascript. Can I be guided in this context if its possible or not??? I am using virtuemart extension in joomla to make an ecommerce website. I will try to explain my requirement with the example. Following is the sample category tree with number. 1.0 .....1.1 ..........1.1.1 ..........1.1.2 .....1.2 ..........1.2.1 ..........1.2.2 .....1.3 ..........1.3.1 ..........1.3.2 2.0 .....2.1 ..........2.1.1 ..........2.1.2 .....2.2 ..........2.2.1 ..........2.2.2 .....2.3 ..........2.3.1 ..........2.3.2 Now I have a drop down main menu as 1.0 and 2.0. I want that when i click on 1.0 all the nodes of 1.0 should be opened and 2.0 should be closed and similarly when i click on 2.0 all its child nodes should be opened and 1.0 should be closed. What happen with most extensions is that at a time only one child is opened. If i click on 1.0 then only 1.1 or 1.2 or 1.3 will remain open at a time. Does this kind of customization can be done or is available in javascript .... I hope i will be helped... Thanks a lot for the time. Dear all, Below are my current script. I need another few more sets of the triple drop down menu same as the below script... (Scenario: creating like a online shopping order form, where customers can have multiple orders.) Please guide me how to do so.. Thank you in advance. <script type="text/javascript"> /* Triple Combo Script Credit By Philip M: http://www.codingforums.com/member.php?u=186 Visit http://javascriptkit.com for this and over 400+ other scripts */ var categories = []; categories["startList"] = ["Wearing Apparel","Books"] categories["Wearing Apparel"] = ["Men","Women","Children"]; categories["Books"] = ["Biography","Fiction","Nonfiction"]; categories["Men"] = ["Shirts","Ties","Belts","Hats"]; categories["Women"] = ["Blouses","Skirts","Scarves", "Hats"]; categories["Children"] = ["Shorts", "Socks", "Coats", "Nightwear"]; categories["Biography"] = ["Contemporay","Historical","Other"]; categories["Fiction"] = ["Science Fiction","Romance", "Thrillers", "Crime"]; categories["Nonfiction"] = ["How-To","Travel","Cookbooks", "Old Churches"]; var nLists = 3; // number of select lists in the set function fillSelect(currCat,currList){ var step = Number(currList.name.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms['tripleplay']['List'+i].length = 1; document.forms['tripleplay']['List'+i].selectedIndex = 0; } var nCat = categories[currCat]; for (each in nCat) { var nOption = document.createElement('option'); var nData = document.createTextNode(nCat[each]); nOption.setAttribute('value',nCat[each]); nOption.appendChild(nData); currList.appendChild(nOption); } } function getValue(L3, L2, L1) { alert("Your selection was:- \n" + L1 + "\n" + L2 + "\n" + L3); } function init() { fillSelect('startList',document.forms['tripleplay']['List1']) } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <form name="tripleplay" action=""> <select name='List1' onchange="fillSelect(this.value,this.form['List2'])"> <option selected>Make a selection</option> </select> <select name='List2' onchange="fillSelect(this.value,this.form['List3'])"> <option selected>Make a selection</option> </select> <select name='List3' onchange="getValue(this.value, this.form['List2'].value, this.form['List1'].value)"> <option selected >Make a selection</option> </select> </form> </body> </html> Hello all, Firstly apologies for my javascript ignorance - I'm not a programmer, just someone thrust into programming since there's no-one else at my company who can do it. I found a nice js script online for a drop-down menu where the drop downs both expand to their full size and fade-in (very quickly) from transparent. The script in action can be seen on the script writer's site he http://sandbox.leigeber.com/dropdown-menu/index.html and the script is: Code: var menu=function(){ var t=15,z=50,s=6,a; function dd(n){this.n=n; this.h=[]; this.c=[]} dd.prototype.init=function(p,c){ a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0; for(i;i<l;i++){ var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i]; h.onmouseover=new Function(this.n+'.st('+i+',true)'); h.onmouseout=new Function(this.n+'.st('+i+')'); } } dd.prototype.st=function(x,f){ var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0]; clearInterval(c.t); c.style.overflow='hidden'; if(f){ p.className+=' '+a; if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0} if(c.mh==c.offsetHeight){c.style.overflow='visible'} else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)} }else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)} } function sl(c,f){ var h=c.offsetHeight; if((h<=0&&f!=1)||(h>=c.mh&&f==1)){ if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'} clearInterval(c.t); return } var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh; c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')'; c.style.height=h+(d*f)+'px' } return{dd:dd} }(); with Code: var menu=new menu.dd("menu"); menu.init("menu","menuhover"); used on my html page to call the script. I'm using the script exactly as written and exactly as it is on the dude's demo page for it. However, some of my sub-menu items are wider than their parent items and in IE7 this means they are bound to the width of the parent until the animations have finished, and then pop-out to their full width (NB not an issue in FF3). I'm actually not too fussed about either the fade in or expand out effects (they'd be nice, but not at the expense of the IE7 bug) so I simply wanted to know what I should do to the script to turn off the effects, or make them instant - ie reduce the length of the effect to as short as possible. I understand I can get rid of the bug by specifying a width for the ul element in my css, but I'd rather not do that if I can help it. I'd appreciate anyone's insight on this. Thanks Tom hello everyone im coding a website at the moment using aspx and i have came to a snag. im trying to make a dropdown list which is populated by an array call my chaletDetails.aspx page - each item in the array will be directed to this page. ive diffled abit, but the more i do the more im afraid of breaking something lol. if someone could maybe look at the code and show me how this could be achieved id appriciate it very much. The code i have for my dropdown list is as follows... this is in divResorts.js var resorts = new Array("Adelboden", "Auron", "Oppdal", "Las Lenas", "La Pierre St Martin", "Val Ceneis", "Les Menuires", "Champex-Lac", "Puy St Vincent"); function populateSelectList() { var mystring = document.getElementById('divResort').innerHTML mystring += "<h4>Our Resorts</h4><select name='resorts'>" mystring += "<option>Choose a Resort</option>" for (i = 0; i < resorts.length; i++) { mystring += "<option value='" + resorts[i] + "'>" mystring += resorts[i] + "</option>" } mystring += "</select>" mystring += "<h4>Our Chalets</h4>" document.getElementById('divResort').innerHTML = mystring } within the body i have this called as: <div id="divResort"> <script type="text/javascript">populateSelectList();</script> </div> Hi Guys, Im in need of some help with regards to forms. I am looking to build as basic as possible, a form that has 3 select dropdowns that have predetermined options. The user will select the first option and based on that option the second will populate and based on that, the third one will give the last option. Now, when the last one is selected, i need a div or a paragraph displaying information to be displayed. So here's the framework. Option 1 = fruit or vegitables of which fruit is selected is selected by the user Option 2 = Apples, Grapes, and pears of which apples is then selected Option 3 = Red, Green and Yellow of which Green is selected. Once green is selected, I need a description about the green aple to be displayed. Can anyone help me out on this? I am not sure where to begin and my boss is adament it must be done like yesterday. Ay help will be appreciated. Thanks. I am trying to do what I thought was a very simple animated menu. I have a heading at the top of a website - which is just a png. I have a menu that is simply a div with a few options on it arranged horizontally. There's no submenus, it's just a very simple horizontal list. All I am trying to do is to hide the menu and then when you mouseover the heading, it will drop down. When you mouseout, it will move back up. It would be great if it faded in as it moved down too. Am sure it's probably very simple, but I've looked all over Google and I can't find a simple solution that doesn't do X, Y and Z that I don't want or need in this project. I just need a very simple script that I stand half a hope of understanding! I am trying to get the menu bar to also have a "<" on the other side, so i can control the menu to the left also, Thanks in advance Code: <style> #hmenu {position:absolute; overflow: hidden; left: -275px; width:350px; height:30px; border: solid 1px #339900; padding: 5px; font-family: arial, sans-serif;} #harrow {position: absolute; left: 325px; top: 5px; border: solid 1px #339900; font-weight: bold; width:20px; height: 18px; text-align:center; background-color:#336600; } a {text-decoration: none;} #harrow a {color: white} </style> <script> function move(menu_id,mTop,mLeft){ var obj = document.getElementById(menu_id); obj.style.top = obj.offsetTop+mTop +"px"; obj.style.left = obj.offsetLeft+mLeft+"px"; } </script> </HEAD> <BODY> <div id=hmenu> <a href=#>Link 1</a> | <a href=#>Link 2</a> | <a href=#>Link 3</a> | <a href=#>Link 4</a> | <a href=#>Link 5</a> <div id=harrow><a href="#" onclick="move('hmenu',0,295)"> > </a></div> |