Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - random image and its url -


i want create random image , url, mean not link of image, in addition image's link, want specified url, random image displayed , when u click on it, u go specified url

here javascript:

    function random_imglink(){       var myimages=new array()       //specify random images below. can have many wish       myimages[1]="/documents/templates/projedepo/banner/canon.jpg"       myimages[2]="/documents/templates/projedepo/banner/indigovision.jpg"        var ry=math.floor(math.random()*myimages.length)        if (ry==0)          ry=1      var randomimage = '<img src="'+myimages[ry]+'" height="420" width="964" />';     document.getelementbyid("image2").innerhtml = randomimage;     }     random_imglink() 

here html:

<div id="slider_container">     <div id="image2"> </div> <div id="thumb2"> <a href="#" rel="/documents/templates/projedepo/banner/canon.jpg" class="image2" ><img title="canon" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t1.png" border="0"/></a> <a href="#" rel="/documents/templates/projedepo/banner/indigovision.jpg" class="image2"><img title="indogovision" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t2.png" border="0"/></a> </div></div> 

i'm not entirely sure want do, think want create single image links url, chosen @ random list of images , corresponding urls. this:

function random_imglink() {     var myimages = [         {image: "/documents/templates/projedepo/banner/canon.jpg", url: "http://www.url1.com"},         {image: "/documents/templates/projedepo/banner/indigovision.jpg", url: "http://www.url2.com"}     ];      var ry=math.floor(math.random()*myimages.length);      var randomimage = myimages[ry];      var randomimagelink = '<a href="' + randomimage.url + '"><img src="'+randomimage.image+'" height="420" width="964" /></a>';     document.getelementbyid("image2").innerhtml = randomimagelink; } 

i'm using [] here create array, starts @ index 0 (see: http://www.hunlock.com/blogs/mastering_javascript_arrays). because of this, don't need if (ry == 0) ry = 1; part. things in {} javascript objects, can use associative (key-value) arrays. see http://www.quirksmode.org/js/associative.html.

maybe know of this, in case please disregard said :)

edit:

by way, if want little bit nicer , there image , link in image2 div, put non-dynamic stuff in html:

<div id="image2">     <a id="image2-link" href="#"><img id="image2-image" src="" height="420" width="964" /></a> </div> 

and then

(...)      var randomimage = myimages[ry];      document.getelementbyid("image2-link").href = randomimage.url;     document.getelementbyid("image2-image").src = randomimage.image; 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -