Presmurdu - Pakistani Urdu Forum | urdu shayari | Urdu Islam | Design Urdu Poetry
Aslam-O-Alekum
mhotram guest ager ap www.presmurdu.com k member hain tu yahan sa login hun....
ager ap member nahi hain tu yahan sa ap humara es forum ma Register ho sakta hain.......




















Share
View previous topicGo downView next topic
avatar
Moderator
Moderator
Breezy
User Title
Posts Posts : 230
Rep Points Rep Points : 254
Thanks Thanks : 0
Age Age : 37
150 / 999150 / 999
0 / 1500 / 150
Gender : Male
View user profile

default Animated Random Option Combo Javascripts

on Sun Oct 23, 2011 4:35 pm
This is a unique combo menu script that lets the user make a URL selection in two ways:

By directly selecting the option you wish to go to, or
Let the script randomly decide for you, by cycling through all available options and picking one randomly.


Step 1: Insert the below into the <HEAD> section of your page:

Code:
<script type="text/javascript">

/***********************************************
* Animated Random Option Combo- by presmurdu.com (www.presmurdu.com)
* This notice must stay intact for usage
* Visit Presmurdu http://www.presmurdu.com/ for this script and 100s more
***********************************************/

var animatedList={

navigate:function(selectId){
   this.selectObj=document.getElementById(selectId)
   window.location=this.selectObj[this.selectObj.selectedIndex].value
},

randomizeInit:function(selectId){
   this.selectObj=document.getElementById(selectId)
   this.curframe=0
   this.optionscount=this.selectObj.options.length
 //calculate number of frames to animate (cycle through options before settling on one)
   this.maxframes=Math.floor(Math.random()*this.optionscount)+Math.floor(Math.random()*this.optionscount)
   this.randomize()
},


randomize:function(){
   if (this.curframe<this.maxframes)
      this.selectObj.selectedIndex=this.settledIndex=(this.curframe<this.optionscount)? this.curframe : this.curframe-this.optionscount
   else{ //settle on and select this option
      this.selectObj.selectedIndex=(this.selectObj.selectedIndex==-1)? this.settledIndex : -1
   }
   this.curframe++
   if (this.curframe<this.maxframes+4) //Keep running this function until "maxframes" cycle plus 4 (4 being cycle for highlighting selected option)
      setTimeout("animatedList.randomize()", 100)
   else
      window.location=this.selectObj[this.selectObj.selectedIndex].value
}

}

</script>

Step 2: Insert the below two sample combo boxes the <body> section of your page:
Code:

<form>
<select id="webdevlinks" size="6" onChange="animatedList.navigate('webdevlinks')">
<option value="http://www.presmurdu.com">Presmurdu Pakistani Forum</option>
<option value="http://www.Presmurdu.com/jsref/">JavaScript Reference</option>
<option value="http://www.presmurdu.com/domref/">DOM Reference</option>
<option value="http://www.codingforums.com">CodingForums.com</option>
<option value="http://www.cssdrive.com">CSS Drive</option>
<option value="http://www.dynamicdrive.com">Dynamic Drive</option>
</select><br />
<input type="button" onClick="animatedList.randomizeInit('webdevlinks')" value="Random Link!" />
</form>


<form>
<select id="newslinks" size="1" onChange="animatedList.navigate('newslinks')">
<option value="http://www.cnn.com/">CNN</option>
<option value="http://www.msnbc.com">MSNBC</option>
<option value="http://news.bbc.co.uk">BBC News</option>
<option value="http://news.yahoo.com/">Yahoo News</option>
</select> <input type="button" onClick="animatedList.navigate('newslinks')" value="Go" /> <input type="button" onClick="animatedList.randomizeInit('newslinks')" value="Random" />
</form>







Love You Presmurdu


Happiness is a perfume.
You cannot spread on others without getting a few drops on urself.
So always be happy to make others happy !


avatar
Moderator
Moderator
Angelic
cute_angel
Posts Posts : 8631
Rep Points Rep Points : 8683
Thanks Thanks : 34
350 / 999350 / 999
0 / 1500 / 150
Awards Showcase Awards Showcase :
View user profile

default Re: Animated Random Option Combo Javascripts

on Mon Oct 24, 2011 5:25 pm
v nice sharing keep it up


Arzoo.........

Nothing is good or bad,but thinking makes it so....



View previous topicBack to topView next topic
Permissions in this forum:
You cannot reply to topics in this forum