How to do this code to display two banners to each other?

Page 1 of 2 1, 2  Next

Go down

Solved How to do this code to display two banners to each other?

Post by smurfavr on Tue Oct 20, 2015 10:11 pm

How to do this code to display two banners to each other?




Code:
<div align="center">
                                   <script language="JavaScript">
<!--
function random_imglink(){
var myimages=new Array()

myimages[1]="http://i39.servimg.com"
myimages[2]="http://i38.servimg.com"
myimages[3]="http://i21.servimg.com"
myimages[4]="http://i58.servimg.com"
myimages[5]="http://i58.servimg.com"
myimages[6]="http://i19.servimg.com"
myimages[7]="http://i21.servimg.com"

var imagelinks=new Array()
imagelinks[1]="http://xxxxxxx"
imagelinks[2]="http://xxxxxxx"
imagelinks[3]="http://xxxxxxx"
imagelinks[4]="http://xxxxxxx"
imagelinks[5]="http://xxxxxxx"
imagelinks[6]="http://xxxxxxx"
imagelinks[7]="http://xxxxxxx"



var ry=Math.floor(Math.random()*myimages.length)

if (ry==0)
ry=1
document.write('<a href='+'"'+imagelinks[ry]+'"'+' target="_blank"><img src="'+myimages[ry]+'" border=0></a>')
}

random_imglink()
//-->
</script>
</div>


Last edited by smurfavr on Mon Oct 26, 2015 9:46 am; edited 1 time in total
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by SLGray on Wed Oct 21, 2015 3:38 pm

You can use a table to have two images beside each other.


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43514
Reputation : 3094
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Wed Oct 21, 2015 8:31 pm

I do not know how to do it.
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by SLGray on Wed Oct 21, 2015 8:45 pm

Code:
[table][tr][td][img]IMAGE URL[/img][/td]
[td][img]IMAGE URL[/img][/td]
[/tr]
[/table]


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 43514
Reputation : 3094
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Thu Oct 22, 2015 8:31 am

I do not know how to do it. Can you do it in the code that I have given.
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 2:11 am

Up
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Guest on Sat Oct 24, 2015 2:47 am

Hi there,

Can you provide the two images? Links preferably.

Guest
Guest


Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 5:29 am



avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Guest on Sat Oct 24, 2015 5:37 am

Where exactly are you going to display them?

Guest
Guest


Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 5:51 am

In the middle of my website.
http://smurfa.bulgarianforum.net/portal
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Guest on Sat Oct 24, 2015 5:54 am

Here you are!

Code:
<table style="width: 100%;" cellpadding="5" cellspacing="5" border="0">
              
   <tbody>
      <tr>
              
         <td>
                <img src="http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif" /><br />   
         </td>
              
         <td>
                <img src="http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif" /><br />   
         </td>
              
      </tr>
           
   </tbody>
</table><br />

Guest
Guest


Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 6:00 am

I want to do in the code that I gave because I have many banners, which must be put.

https://help.forumotion.com/t143948-how-to-do-this-code-to-display-two-banners-to-each-other#982769
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Guest on Sat Oct 24, 2015 6:03 am

But the thing I gave does work, yes? If so, how many more banners do you need?

Guest
Guest


Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 6:08 am

I have a 7 to 10 bars of different sites that have banner exchange. I want to use this code because it is a rotation of banners.

Code:
myimages[1]="http://i39.servimg.com"
myimages[2]="http://i38.servimg.com"
myimages[3]="http://i21.servimg.com"
myimages[4]="http://i58.servimg.com"
myimages[5]="http://i58.servimg.com"
myimages[6]="http://i19.servimg.com"
myimages[7]="http://i21.servimg.com"

var imagelinks=new Array()
imagelinks[1]="http://xxxxxxx"
imagelinks[2]="http://xxxxxxx"
imagelinks[3]="http://xxxxxxx"
imagelinks[4]="http://xxxxxxx"
imagelinks[5]="http://xxxxxxx"
imagelinks[6]="http://xxxxxxx"
imagelinks[7]="http://xxxxxxx"
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Guest on Sat Oct 24, 2015 6:10 am

Yes, that is correct. I just tested that code with the two banners you gave me and it seemed to had worked just fine.

Guest
Guest


Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 6:13 am

This code currently working on my website, but I want to do it to display two banners because currently shows only one banner.
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Guest on Sat Oct 24, 2015 6:17 am

Oh, now I understand. Okay, I'll see what I can come up with.

Guest
Guest


Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sat Oct 24, 2015 6:23 am

ок
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on Sat Oct 24, 2015 6:34 am

Hi @smurfavr,

Try this instead :
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index];
   
    _randomImages.splice(index, 1);
    return img;
  };
 
  document.write('<img src="' + _randomImage() + '"/><img src="' + _randomImage() + '"/>');
}());</script>

You can paste this wherever HTML and <script> formats, such as homepage message, widgets, or an html page. At the top you can indicate an image list, with multiple images being separated by a comma.
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sun Oct 25, 2015 12:29 am

By pressing the banner does not open a new page to the site which is the banner.
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on Sun Oct 25, 2015 3:23 am

Replace the script with this :
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ], _randomURLs [
    '',
    ''
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index]
        url = _randomURLs[index];
   
    _randomImages.splice(index, 1);
    _randomURLs.splice(index, 1);
    return '<a href="' + url + '"><img src="' + img + '"/></a>';
  };
 
  document.write(_randomImage() + _randomImage());
}());</script>

I added _randomURLs so you can place the URL of the images. Make sure they're in the same order as the images they're related to.
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sun Oct 25, 2015 8:04 am


Correctly made code?
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ], _randomURLs [
    'http://smurfa.bulgarianforum.net/',
    'http://smurfa.bulgarianforum.net/'
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index]
        url = _randomURLs[index];
   
    _randomImages.splice(index, 1);
    _randomURLs.splice(index, 1);
    return '<a href="' + url + '"><img src="' + img + '"/></a>';
  };
 
  document.write(_randomImage() + _randomImage());
}());</script>

I did not understand where to put it.

1.HTML pages management
2.Javascript codes management
3.widget
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on Sun Oct 25, 2015 9:26 am

It can go in a widget, html page, homepage message, etc. Since it includes the HTML <script> tag it shouldn't be placed in JS codes management.
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Sun Oct 25, 2015 9:52 am

I can not figure out how to do it. Google does not translate correctly. Grr
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on Sun Oct 25, 2015 10:01 am

Anywhere HTML formats, except posts. ^^

1. HTML Pages management
2. Widget
3. Homepage message
4. Announcement
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Michael_vx on Mon Oct 26, 2015 2:39 am

hi sorry for jump in first
i tested the Code
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ], _randomURLs [
    'http://smurfa.bulgarianforum.net/',
    'http://smurfa.bulgarianforum.net/'
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index]
        url = _randomURLs[index];
   
    _randomImages.splice(index, 1);
    _randomURLs.splice(index, 1);
    return '<a href="' + url + '"><img src="' + img + '"/></a>';
  };
 
  document.write(_randomImage() + _randomImage());
}());</script>
it wont show any thing im not sure is that my problem or there something missing i cant figure it on the Script
sorry for jumping in a topic dose not belong to me
avatar
Michael_vx
Forumember

Male Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on Mon Oct 26, 2015 3:41 am

@Michael_vx you're right, I forgot a comma and an assignment operator. Shocked

I fixed it, so try now :
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ], _randomURLs = [
    'http://smurfa.bulgarianforum.net/',
    'http://smurfa.bulgarianforum.net/'
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index],
        url = _randomURLs[index];
   
    _randomImages.splice(index, 1);
    _randomURLs.splice(index, 1);
    return '<a href="' + url + '"><img src="' + img + '"/></a>';
  };
 
  document.write(_randomImage() + _randomImage());
}());</script>
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Michael_vx on Mon Oct 26, 2015 7:12 am

Shocked
do my eyes got blind or im getting more stupid because i didnt figure the comma and an assignment operator places are
i think i have one last question
how many images can that Script handle and dose it work like slide or not thanks again and i good luck to the topic owner
avatar
Michael_vx
Forumember

Male Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by smurfavr on Mon Oct 26, 2015 7:42 am

@Ange Tuteur
Banners are displayed below each other. I want to show to each other.
Can you do it by clicking the banner to open a new page.
Can you add banners to be displayed on a rotating basis.

He had those things in the code that I have given in my first post.
avatar
smurfavr
Active Poster

Male Posts : 1693
Reputation : 17
Language : Bulgarian

http://smurfa.bulgarianforum.net/

Back to top Go down

Solved Re: How to do this code to display two banners to each other?

Post by Ange Tuteur on Mon Oct 26, 2015 8:17 am

Replace the code with this :
Code:
<script type="text/javascript">(function() {
  var _randomImages = [
    'http://i58.servimg.com/u/f58/16/34/78/03/sait-g11.gif',
    'http://i58.servimg.com/u/f58/16/34/78/03/new-ne11.gif'
  ], _randomURLs = [
    'http://smurfa.bulgarianforum.net/',
    'http://smurfa.bulgarianforum.net/'
  ];
 
  function _randomImage() {
    var index = Math.floor(Math.random() * _randomImages.length),
        img = _randomImages[index],
        url = _randomURLs[index];
   
    _randomImages.splice(index, 1);
    _randomURLs.splice(index, 1);
    return '<a href="' + url + '"><img src="' + img + '"/></a>';
  };
 
  document.write('<div id="randomBanner">' + _randomImage() + _randomImage() + '</div>');
}());</script>

and then add 1 of the following CSS codes to your stylesheet.

If you want the images to fit side-by-side regardless of resolution :
Code:
#randomBanner img {
  width:50%;
}

If you want a scroll bar :
Code:
#randomBanner  {
  width:100%;
  white-space:nowrap;
  overflow-y:auto;
}
avatar
Ange Tuteur
Forumaster

Male Posts : 13202
Reputation : 2918
Language : EN10, FR5, JA5
Location : Macungie, PA

https://github.com/SethClydesdale

Back to top Go down

Page 1 of 2 1, 2  Next

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum