JavaScript - Multiple Effects
plz i want to know how to make the effects that exists on this link in the upper part :
http://www.masrawy.com/new/ 1-) changing color when pressing on the color 2-) changing font (+) to increase it (-) to decrease it (N) to set it to the normal style 3-) decrease and increase the width of the page (from كبر حجم الصفحة or صغر حجم الصفحة ) can anyone help me in doing this task????? Similar TutorialsI need help with the script for multiple mouseOver Effects for my Menu Bar. The script I have is: <script type="text/javascript"> function mouseOver() { document.getElementById("b1").src ="home1.jpg"; } function mouseOut() { document.getElementById("b1").src ="home.jpg"; } </script> <A HREF="Index.html" rel="nofollow" target="_blank"><img src="home.jpg" id="b1" width="167" height="60" onmouseover="mouseOver()" onmouseout="mouseOut()"/></A> However, that only does one mouseover effect. Can someone help me with this? Hi Coders, I have been trying to achieve a multiple mouseover effect on some of my pictures within my web page. The first effect changes the picture within a table - works fine The second effect should change the text within another table. - does not work. I am receiving the error message: 'document.text' is null or not an object. Here is the code which lies on my image: Code: <td style="height: 101px; width: 20%" valign="top"> <img onMouseover="changeimage(myimages[1],this.href); newchange();" alt="loading" height="86" src="images/marsrover_sml.jpg" width="104" /></td> Here is the newchange() script: Code: <script language="JavaScript1.1"> function newchange() { document.text.innerHTML='<b>hello world</b>' } </script> And I am sure that the table in which the text should appear has its Id and Name defined as "text" Here is it: Code: <td class="style5" Id="text" name="text" style="height: 29px; width: 525px" valign="top"> <strong class="style10">Endavour has launched</strong></td> But could not make it work error free. Thanks for any comments. hi all, i am using this javascript code which i found on a random website to create a tooltip style popup. in my head is: Code: <script type="text/javascript"> function showmenu(elmnt) { document.getElementById(elmnt).style.visibility="visible" } function hidemenu(elmnt) { document.getElementById(elmnt).style.visibility="hidden" } </script> <style type="text/javascript"> #twittericon { position: fixed; bottom:148px; left: 6%; width: 33px; height:29px; z-index: 49; } #tweet{ position:fixed; bottom:178px; left: 3%; max-width:310px; color:#333333; font-family:Arial Narrow,Arial,Sans-serif; font-size:12px;; z-index:6000; visibility: hidden; } </style> in my body is: Code: <div id="twittericon" onMouseOver="showmenu('tweet')" onMouseOut="hidemenu('tweet')"> <a href="http://twitter.com/bubblejam" target="_blank"> <img src="http://nang-nang.net/tumblr/blog/twit-bird.gif" width="33" height="29" /></a> </div> <div id="tweet"> (latest tweet generating code) </div> this creates a little bird, which displays latest tweet when rolled-over. you can see a working example of this he http://nang-nang.net/tumblr/blog/try.html my question a (1) can i add something to the javascript to create a delay when onMouseOut so that the tweet doesn't disappear immediately? also (2) could i also add something to the javascript to create a visual effect when onMouseOver or onMouseOut occurs? like a fade in effect? or slide up effect? i've been playing around with scriptaculous effects but i'm not sure how to combine that script with my script above. an answer to (1) at least would be very much appreciated! please i want to know how to make lightbox effects with the idea of switching between pages using the lightbox please follow this link: http://particletree.com/examples/lightbox/ while pressing on "submit an inquiry " it will show a form... all that i need is to make the same idea but using registration form first page: contains user data ---> on pressing next .. i want to be on same lightbox box effect but using next page that contains his work data... and on third page he will have a message that his registration is done successfully.. so how to switch between pages in lightbox effects??? this js file disables the toggle from all my effects. any idea how to fix this problem without deleting this? Code: // SpryDOMEffects.js - version 0.6 - Spry Pre-Release 1.7 // // Copyright (c) 2007. Adobe Systems Incorporated. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // * Neither the name of Adobe Systems Incorporated nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. (function() { // BeginSpryComponent if (typeof Spry == "undefined" || !Spry.Utils || !Spry.$$) { alert("SpryDOMEffects.js requires SpryDOMUtils.js"); return; } if (!Spry.Effect) Spry.Effect = {}; Spry.Effect.Animator = function(opts) { Spry.Effect.Animator.Notifier.call(this); this.animatorID = Spry.Effect.Animator.nextID++; this.dropFrames = true; this.fps = 60; // frames per-second this.duration = 500; // msecs this.timer = 0; this.startTime = 0; // Used only when dropFrames is true. this.currentFrame = 0; this.easeFunc = Spry.Effect.Animator.defaultEaseFunc; this.stopped = false; Spry.Effect.Animator.copyProps(this, opts); this.interval = 1000 / this.fps; this.numFrames = (this.duration / 1000) * this.fps; if (this.onComplete) { var self = this; this.addObserver({ onAnimationComplete: function(){ self.onComplete(); } }); } }; Spry.Effect.Animator.nextID = 1; Spry.Effect.Animator.copyProps = function(dst, src) { if (src) { for (prop in src) dst[prop] = src[prop]; } return dst; }; Spry.Effect.Animator.getElement = function(element) { if (arguments.length > 1) { for (var i = 0, elements = [], length = arguments.length; i < length; i++) elements.push(Spry.Effect.Animator.getElement(arguments[i])); return elements; } if (typeof element == 'string') element = document.getElementById(element); return element; }; Spry.Effect.Animator.defaultEaseFunc = function(time, begin, finish, duration) { time /= duration; return begin + ((2 - time) * time * finish); }; Spry.Effect.Animator.Notifier = function() { this.observers = []; this.suppressNotifications = 0; }; Spry.Effect.Animator.Notifier.prototype.addObserver = function(observer) { if (!observer) return; // Make sure the observer isn't already on the list. var len = this.observers.length; for (var i = 0; i < len; i++) { if (this.observers[i] == observer) return; } this.observers[len] = observer; }; Spry.Effect.Animator.Notifier.prototype.removeObserver = function(observer) { if (!observer) return; for (var i = 0; i < this.observers.length; i++) { if (this.observers[i] == observer) { this.observers.splice(i, 1); break; } } }; Spry.Effect.Animator.Notifier.prototype.notifyObservers = function(methodName, data) { if (!methodName) return; if (!this.suppressNotifications) { var len = this.observers.length; for (var i = 0; i < len; i++) { var obs = this.observers[i]; if (obs) { if (typeof obs == "function") obs(methodName, this, data); else if (obs[methodName]) obs[methodName](this, data); } } } }; Spry.Effect.Animator.Notifier.prototype.enableNotifications = function() { if (--this.suppressNotifications < 0) { this.suppressNotifications = 0; Spry.Debug.reportError("Unbalanced enableNotifications() call!\n"); } }; Spry.Effect.Animator.Notifier.prototype.disableNotifications = function() { ++this.suppressNotifications; }; Spry.Effect.Animator.prototype = new Spry.Effect.Animator.Notifier; Spry.Effect.Animator.prototype.constructor = Spry.Effect.Animator; Spry.Effect.Animator.prototype.start = function() { this.stopped = false; this.currentFrame = 0; this.startTime = (new Date()).getTime(); this.notifyObservers("onAnimationStart"); var self = this; this.timer = setTimeout(function(){ self.onStepAnimation(); }, this.interval); }; Spry.Effect.Animator.prototype.stop = function() { if (this.timer) clearTimeout(this.timer); this.timer = 0; this.stopped = true; this.notifyObservers("onAnimationStopped"); }; Spry.Effect.Animator.prototype.onStepAnimation = function() { var obj = {}; if (this.dropFrames) { obj.duration = this.duration; obj.elapsed = ((new Date).getTime()) - this.startTime; if (obj.elapsed > obj.duration) obj.elapsed = obj.duration; } else { obj.duration = this.numFrames; obj.elapsed = ++this.currentFrame; } obj.easingConst = this.easeFunc(obj.elapsed, 0, 1, obj.duration) this.notifyObservers("onPreDraw", obj); this.draw(obj.elapsed, obj.duration, obj.easingConst); this.notifyObservers("onPostDraw", obj); if (!this.stopped) { if (obj.elapsed < obj.duration) { var self = this; this.timer = setTimeout(function(){ self.onStepAnimation(); }, this.interval); } else { this.stop(); this.notifyObservers("onAnimationComplete"); } } }; Spry.Effect.Animator.prototype.draw = function(elapsed, duration, easingConst) { // The default draw method does nothing. It is assumed that // derived classes will provide their own implementation of this // method. debug.log("elapsed: " + elapsed + " -- duration: " + duration + " -- easingConst: " + easingConst); }; /////////////////////////////////////////////////////////////////////////////// Spry.Effect.CSSAnimator = function(elements, styleStr, opts) { this.animationSets = []; Spry.Effect.Animator.call(this, opts); this.add(elements, styleStr); }; Spry.Effect.CSSAnimator.prototype = new Spry.Effect.Animator(); Spry.Effect.CSSAnimator.prototype.constructor = Spry.Effect.CSSAnimator; Spry.Effect.CSSAnimator.prototype.add = function(elements, styleStr) { // The first argument for the CSSAnimator can be // the id of an element, an element node, or an array of // elements and/or ids. elements = Spry.$$(elements); if (elements.length < 1) return; var animSet = { elements: elements, cssProps: []}; this.animationSets.push(animSet); // Convert the styleStr into an object. var toObj = Spry.Utils.styleStringToObject(styleStr); for (var p in toObj) { var obj = new Object; var v = toObj[p]; obj.value = new Number(v.replace(/[^-\d\.]+/g, "")); obj.units = v.replace(/[-\d+\.]/g, ""); toObj[p] = obj; } for (var i = 0; i < elements.length; i++) { var obj = animSet.cssProps[i] = new Object; for (var p in toObj) { var pFuncs = Spry.Effect.CSSAnimator.stylePropFuncs[p]; if (!pFuncs) pFuncs = Spry.Effect.CSSAnimator.stylePropFuncs["default"]; obj[p] = new Object; obj[p].from = new Number(pFuncs.get(elements[i], p).replace(/[^-\d\.]+/g, "")); obj[p].to = toObj[p].value; obj[p].distance = obj[p].to - obj[p].from; obj[p].units = toObj[p].units; } } }; Spry.Effect.CSSAnimator.prototype.start = function() { for (var s = 0; s < this.animationSets.length; s++) { var animSet = this.animationSets[s]; var elements = animSet.elements; var cssProps = animSet.cssProps; for (var i = 0; i < elements.length; i++) { var ele = elements[i]; var eleProps = ele.spryCSSAnimatorProps; if (!eleProps) eleProps = ele.spryCSSAnimatorProps = new Object; var obj = cssProps[i]; for (var p in obj) eleProps[p] = this.animatorID; } } return Spry.Effect.Animator.prototype.start.call(this); }; Spry.Effect.CSSAnimator.prototype.stop = function() { for (var s = 0; s < this.animationSets.length; s++) { var animSet = this.animationSets[s]; var elements = animSet.elements; var cssProps = animSet.cssProps; for (var i = 0; i < elements.length; i++) { var ele = elements[i]; var obj = cssProps[i]; var eleProps = ele.spryCSSAnimatorProps; for (var p in obj) { if (eleProps[p] == this.animatorID) delete eleProps[p]; } } } return Spry.Effect.Animator.prototype.stop.call(this); }; Spry.Effect.CSSAnimator.prototype.draw = function(elapsed, duration, easingConst) { for (var s = 0; s < this.animationSets.length; s++) { var animSet = this.animationSets[s]; var elements = animSet.elements; var cssProps = animSet.cssProps; for (var i = 0; i < elements.length; i++) { var ele = elements[i]; var eleProps = ele.spryCSSAnimatorProps; var obj = cssProps[i]; for (var p in obj) { if (eleProps[p] == this.animatorID) { var pFuncs = Spry.Effect.CSSAnimator.stylePropFuncs[p]; if (!pFuncs) pFuncs = Spry.Effect.CSSAnimator.stylePropFuncs["default"]; if (elapsed > duration) pFuncs.set(ele, p, obj[p].to + obj[p].units); else pFuncs.set(ele, p, obj[p].from + (obj[p].distance * easingConst) + obj[p].units); } } } } }; Spry.Effect.CSSAnimator.stylePropFuncs = {}; Spry.Effect.CSSAnimator.stylePropFuncs["default"] = { get: function(ele, prop) { return ele.style[prop]; }, set: function(ele, prop, val) { ele.style[prop] = val; } }; Spry.Effect.CSSAnimator.stylePropFuncs["opacity"] = { get: function(ele, prop) { var val = 1; if (ele.style.opacity) val = ele.style.opacity; else if (ele.style.filter) { var strVal = ele.style.filter.replace(/.*alpha\(opacity=(\d+)\).*/, "$1"); if (strVal) val = parseInt(strVal) / 100; } return val + ""; }, set: function(ele, prop, val) { ele.style.opacity = "" + val; ele.style.filter = "alpha(opacity=" + (val * 100) + ")"; } }; /////////////////////////////////////////////////////////////////////////////// Spry.$$.Results.defaultEaseFunc = function(time, begin, finish, duration) { time /= duration; return begin + ((2 - time) * time * finish); }; Spry.$$.Results.animatePropertyTo = function(propName, to, options) { var opts = { interval: 10, duration: 1000, onComplete: null, transition: Spry.$$.Results.defaultEaseFunc }; Spry.Effect.Animator.copyProps(opts, options); var objs = []; for (var i = 0; i < this.length; i++) { var obj = objs[i] = new Object; obj.ele = this[i]; obj.from = obj.ele[propName]; obj.distance = to - obj.from; } var startTime = (new Date).getTime(); var animateFunc = function() { var elapsedTime = ((new Date).getTime()) - startTime; if (elapsedTime > opts.duration) { for (var i = 0; i < objs.length; i++) objs[i].ele[propName] = to; if (opts.onComplete) opts.onComplete(); } else { for (var i = 0; i < objs.length; i++) { var obj = objs[i]; obj.ele[propName] = opts.transition(elapsedTime, obj.from, obj.distance, opts.duration); } setTimeout(animateFunc, opts.interval); } }; setTimeout(animateFunc, opts.interval); return this; }; Spry.$$.Results.animateStyleTo = function(styleStr, options) { var a = new Spry.Effect.CSSAnimator(this, styleStr, options); a.start(); return this; }; })(); // EndSpryComponent I am working on implementing a gallery into my website with categories that collapse/expand the set of images within those categories. i figured out mostly everything i need except i can't get the BUTTONS to behave the way that I want. I'm working with the following images: arrow1: arrow2: arrow3: in general, I want "arrow1" to change to "arrow2" whenever you hover a mouse over it, and back to "arrow1" when the mouse is moves away. (which is simple by itself) the complicated part that I can't figure out, is what happens when you CLICK the button. I want the image to change to "arrow3" when it is clicked (because the content expands), and to STAY at that image until it's clicked again, at which point it should behave as what I started with. The problem is, I can get the arrow to change on click no problem, but once the mouse is moved away, the "onMouseOut" effect changes it back to "arrow1". this is the code I'm working with, hope someone can help Code: <SCRIPT LANGUAGE = "JavaScript"> <!-- first=new Image first.src="http://www.clearnonsense.com/images/arrow1.png" second=new Image second.src="http://www.clearnonsense.com/images/arrow2.png" // --></SCRIPT> </HEAD> <table border="0"> <tr> <td> <a href="javascript:void(0)" OnMouseOut="monitor.src=first.src" OnMouseOver="monitor.src=second.src" onMouseUp="clickdown('pic1')"><img src="http://www.clearnonsense.com/images/arrow1.png" border="0" name="monitor" onclick="showhide('div1',this,'http://www.clearnonsense.com/images/arrow1.png','http://www.clearnonsense.com/images/arrow3.png');"/></a> </td> </tr> <tr> <td valign="top" width="15"> <div id="div1" style="display: none;">imgset1</div> </td> </tr> </table> The 2 sites below are animated scrolling pages which I know how to do, What I am looking for is how do they make the effect like the pages are sliding independent "like an overlaid effect" of each other If anyone can show me how they get that effect or if there are any demo or examples to help me figure it out http://www.sketchtravel.com/ http://www.foofighters.com/us/discography thanks for your help -rob Happy Turkey Day!! I am new to JavaScript and I downloaded a code for image mouse over effects. It works exactly how it's supposed to except when you first load the page, the images are not there. They do not appear and function until you actually roll the mouse over them. Here is the script and the link... any help would be greatly appreciated! Thank you Link Code: <script language="javascript"> //script found on www.a1javascripts.com //all credit to unknown author <!-- hide script from old browsers window.onerror = null; var netscape = 0; var goodIE = 0; browserName = navigator.appName.substring(0,8); browserVer = parseFloat(navigator.appVersion); if (browserName == "Netscape" && browserVer >= 3) { netscape = 1; } if (browserName == "Microsof" && browserVer >= 4) { goodIE = 1; } // end error trapping code if (netscape || goodIE) { pic1 = new Image(150,100); pic1.src = "enso.jpg"; pic2 = new Image(150,100); pic2.src = "shine.jpg"; pic3 = new Image(150,100); pic3.src = "samsara.jpg"; pic4 = new Image(150,100); pic4.src = "samsara.jpg"; a1 = new Image(300,200); a1.src = "personal1.jpg"; a2 = new Image(300,200); a2.src = "personal2.jpg"; b1 = new Image(325,225); b1.src = "spiritual1.jpg"; b2 = new Image(325,225); b2.src = "spiritual2.jpg"; c1 = new Image(325,225); c1.src = "eyeent1.jpg"; c2 = new Image(300,200); c2.src = "eyeent2.jpg"; } function hiLite(imgDocID, imgObjName, imgDocID2, imgObjName2, imgDocID3, imgDocID3) { if (netscape || goodIE) { document.images[imgDocID].src = eval(imgObjName + ".src"); document.images[imgDocID2].src = eval(imgObjName2 + ".src"); document.images[imgDocID3].src = eval(imgObjName3 + ".src"); }} //end hiding --> </script> <img alt="Default Image" name="pic" src="default.gif" height="100" width="150" /><br /> <a onclick="window.focus()" onmouseout="hiLite('pic','pic1','a','a1'); window.status='';return true;" onmouseover="hiLite('pic','pic2','a','a2'); window.status='Button 1';return true;" href="your-page.html"><img alt="Button 1" name="a" src="upbutton1.gif" style="border: 0px solid ; width: 325px; height: 225px;" /></a><br /> <a onclick="window.focus()" onmouseout="hiLite('pic','pic1','b','b1'); window.status='';return true;" onmouseover="hiLite('pic','pic3','b','b2'); window.status='Button 2';return true;" href="your-page.html"><img alt="Button 2" name="b" src="upbutton2.gif" style="border: 0px solid ; width: 325px; height: 225px;" /></a> <a onclick="window.focus()" onmouseout="hiLite('pic','pic1','c','c1'); window.status='';return true;" onmouseover="hiLite('pic','pic4','c','c2'); window.status='Button 3';return true;" href="your-page.html"><img alt="Button 3" name="c" src="upbutton3.gif" style="border: 0px solid ; width: 325px; height: 225px;" /></a> Friend i concern with some that man told me , JavaScript programming is the best effective for website development. so how it is tell me ?
Hi guys I am using a customized version of this free css dropdown menu script. It is just pure css, no jquery. I wanted to add some delay to the open and close on mouseover, here is what I added: Code: <script type="text/javascript"> $(document).ready(function () { $('ul.dropdown li').hover( function () { //show its submenu $('ul', this).slideDown(150); }, function () { //hide its submenu $('ul', this).slideUp(250); } ); }); </script> When I first mouse over, this does nothing, but if I mouse over the same drop down li a second time, it works. Check it out here. Any ideas on how I can fix this? I want a Login Box to be opened in modal window when user clicks on a link and authentication is done with Ajax. I tried jQuery BlockUI, jQuery UI, ThickBox. But they are large in scope. I also tried writing separate plugin for my need but i don't have clear idea how does it work. So please either suggest a way or give me link to article which is simple to understand and can clear how it work. Hi, I hope someone can help me. I'll be honest and say I don't know much about javascript, but am fairly comfortable in html. I am building a website that will have multiple image swaps on multiple pages. I am building this in wordpress, and I'm guessing that means my approach will be different than if I wasn't using wordpress. Here's how one page would work: There are 10 images shown. 1,2,3,4,5,6,7,8,9,10. When number 1 is clicked on, I want a new image - 1a. When 2 is clicked on, 2a. So there are 20 different images in all on a given page. Also, I want the user to be able to click on the image again to restore the original image. I would prefer onclick to onmouseover. There will be literally dozens of pages like this on the site, managed by wordpress, so hundreds of images to swap. Basically the first image is a question - the second image is the answer. Is this possible? I have a page of dates in a form field which currently are being entered manually and wish to have a calendar pop up for each one to make it a bit easier. i have managed to use a calendar routine 'tigra calendar' i found online but now after working out not to get it working within my own template i faced the problem on multiple date fields. i currently use a numbers field 1-10 or how every many there needs to be on that page. but how would i integrate this within the coding from 'tigra calendar' can anyone suggest a better way to do this. if needed i can sort out a zip file of the files i have for tigra calendar. Hi, been using javascript for a while now, and wondering how else this could be coded to be more effective and to 'work'. The idea is that the user gets prompted, 'what is your birthday?' the user would put in 0121 or whatever their birthday is, as 01 = month and 21 = day. I'm sure you'll understand what I mean.... Code: <DOCTYPE html> <html> <script> var userAnswer = prompt("When is your birthday? Example: Jan 21st = 0121") </script> <head> </head> <body> <script> if(userAnswer >= 0101){ alert('You are Capricorn!') }; if(userAnswer >= 0120){ alert('You are Aquarius!') }; if(userAnswer >= 0219){ alert('You are Pisces!') }; if(userAnswer >= 0321){ alert('You are Aries') }; if(userAnswer >= 0420){ alert('You are Taurus') }; if(userAnswer >= 0521){ alert('You are Gemini!') }; if(userAnswer >= 0621){ alert('You are Cancer!') }; if(userAnswer >= 0723){ alert('You are Leo!') }; if(userAnswer >= 0823){ alert('You are Virgo!') }; if(userAnswer >= 0923){ alert('You are Libra!') }; if(userAnswer >= 1023){ alert('You are Scorpio!') }; if(userAnswer >= 1122){ alert('You are Sagittarius!') }; if(userAnswer >= 1222){ alert('You are Capricorn!') }; </script> </body> </html> Reply With Quote 01-18-2015, 10:01 AM #2 Mitchellwood101 View Profile View Forum Posts New to the CF scene Join Date Nov 2014 Posts 7 Thanks 0 Thanked 0 Times in 0 Posts And then it will alert the user of their star sign****** Reply With Quote 01-18-2015, 05:47 PM #3 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts If you have been using Javascript for a while now, you should be aware that prompts and alerts are long obsolete, and I would advise that you should not be wasting your time learning this stuff. Use DOM methods to obtain input from and display messages to your users. Be aware that a value starting with 0 is a string, not a number, and so must be in quotes - that is why your code does not work. In any case you need rigorous checking to ensure that the birthday entered in this form is valid, e.g. not 56th Febtember or "Mickey Mouse". You would do best to obtain the input from select lists for month and day, expressed as numbers. A tiny bit more sophistication would allow the user to select a month by name, where the text of the option is the month name, and the value of that option the month number. Code: <select id = "monthlist" onchange = "getSignFunction()"> <option value = "0"> Choose your birth month</option> <option value = 1>January</option> <option value = 2>February</option> ... and so on </select> Then you want something like this:- Code: function getSignFunction()"{ var sign = ""; var month = document.getElementById("monthlist").value; var date = document.getElementById("datelist").value; if (month == 0) {return} // invalid choice if (month == 1 && date >=20 || month == 2 && date <=18) {sign = "Aquarius";} if (month == 2 && date >=19 || month == 3 && date <=20) {sign = "Pisces";} if (month == 3 && date >=21 || month == 4 && date <=19) {sign = "Aries";} if (month == 4 && date >=20 || month == 5 && date <=20) {sign = "Taurus";} if (month == 5 && date >=21 || month == 6 && date <=21) {sign = "Gemini";} if (month == 6 && date >=22 || month == 7 && date <=22) {sign = "Cancer";} if (month == 7 && date >=23 || month == 8 && date <=22) {sign = "Leo";} if (month == 8 && date >=23 || month == 9 && date <=22) {sign = "Virgo";} if (month == 9 && date >=23 || month == 10 && date <=22) {sign = "Libra";} if (month == 10 && date >=23 || month == 11 && date <=21) {sign = "Scorpio";} if (month == 11 && date >=22 || month == 12 && date <=21) {sign = "Sagittarius";} if (month == 12 && date >=22 || month == 1 && date <=19) {sign = "Capricorn";} alert (sign); // alert used here just for testing purposes. Crate as <span> and then use document.getElementById("spanid").innerHTML = sign to display the result to the user. } All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. I'm making a website, and my aim is to have a terminal like interface. I am encountering a problem with startup text. I cannot get it to work right with the following... function title() { document.getElementById("prompts").innerHTML = "OS v0.1"+ setTimeout("<br />> Loading...",2500)+ setTimeout("<br />> FATAL ERROR!",12500)+ setTimeout("<br />> Please enter command.",13500); } However I get undefined for the settimeouts. I have a quick question with multiple array and random numbers. If i generate my random numbers in one array, how would i take a selection of those numbers and put them in another array? Ex: array 1: 25, 34, 38, 40, 22, 49 want to move numbers between 30 and 50 to another array. array 2: 34, 38, 40, 49 is it as simple as for loops and if statements setting the conditions? do i use a sorting method? (selection? bubble?) any help would be appreciated. Hello everyone, I have a problem in redirecting into multiple pages based on if statement result. I have used 3 redirects, only the first one works "redirect1" when I chose any other option.. it always redirects me to the redirect1 page! Please I need your help experts ! The whole code is attached. Hey guys, I'm a noob with javascript and I only know simple HTML coding, so I have become stuck. I can program in other languages though, so I understand the principles. That being said, I have become stuck with something. My aim is to have a series of page where text is displayed, and then two or more buttons. Once a button is clicked, I want the screen to clear and it displays the next lot of text, followed by some more buttons. Once they are pushed, it continues on. So basically, each section has its own code that it pushes, plus its own buttons which lead to other sections. I am not trying to make a choose your own adventure book, but the layout is basically one of these. I can do this in another language by simply having a few sections. Inside each section, it retrieves the option and proceeds. However, when I am trying to do this, I am getting confused. The way my other programming experience tells me to write it, I would write a function which is called for each section, and it would display the text, the buttons, and return to the main function in the program. However, because the buttons are in HTML, I cannot put code for the new buttons instead the functions. If I put the code inside the body of HTML, it will automatically be displayed. I cannot write an if statement to determine which buttons are displayed. Can you please give me some advice around this? I hope I have made myself clear enough to be understood!! One other thing I should mention, I really want to be able to do this in a single HTML file instead of calling other files. I think this would work fine by using frames and multiple HTML files, but I would prefer not to unless I really need to. One file would be much better for me. Thanks! Below is the basic code I am working from. It displays the first section with some text, displays two buttons and it goes to the next section on a button click. Code: <html> <head> <script type="text/javascript"> function button1() { document.write("Button 1 was pushed. Insert text here. Choose from two new buttons below:"); } function button2() { document.write("Button 2 was pushed. Insert text here. Choose from two new buttons below:"); } </script> </head> <body> <form> <input type="button" value="Button1" onClick="button1()" /> <input type="button" value="Button2" onClick="button2()" /> </form> </body> </html> Ok, I have no idea how to really even explain what's been asked of me, but it's seems to me that this could be a bit beyond my knowledge. We're creating an alternate reality game which starts with a series of questions that people can choose from two answers. The answers will determine which path the person will travel. They'll be given a password at the end of the series of questions. There are three possible paths, which means three possible passwords given. On the same page, beneath the questions would be a text box with a "submit" button. The password they are given would be typed in there, and then they'd proceed to the proper page. This keeps from people being able to "skip" the questions portion. What they'd proceed to next is a video which is currently being made for our event, which has hidden puzzles and clues in it to find the next password. Rinse and repeat... My problem? How the heck do I make that box and submit button and password all work together when I have more than one password? Even more so, how do I make the password/submit button direct someone to the correct URL (without revealing the URL, and also prevents anyone from copying the URL and sharing it to bypass the password request)? For example: Questions are complete and the password "invention" is given. The person types in the word invention and presses submit. It directs the to www.url.com/game1 automatically. While someone else will come in, answer the questions, and the password "intelligence" would be given. That person types in the word intelligence and presses submit into the same box, using the same button that the person who typed in the word invention typed in. But this person would instead be directed to www.url.com/game2 If either person shared the link they were directed to, then it'd prompt people to put in a password before letting them in. How in the darn world do I make this happen?? LOL! Thanks in advance for any time, advice, or tutorials provided! ---------------------------------------- Added later.... I might need to go ahead and ask this as well.. since it got me to thinking.. How would I go about hiding the URL as well. I'm only interested in doing it for the game side of the site to keep from people sharing that URL and stripping the "fun" away from the game. Hopefully it is something simple? I'm fairly new at coding. My knowledge is no where as vast as I see many others here are. So if you should decide to have the patience to assist me, please be specific in steps like you are describing this to your kid who has no idea what you're talking about. I hate to present it that way, but I don't want to annoy anyone by stating I don't understand. |