Ir para conteúdo
Fórum CódigoFonte.net
Entre para seguir isso  
Ted k'

Imagens Aleatórias : Randomize

Recommended Posts

Mais um randomize de Imagens adaptado para as necessidade básicas:

<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<%
  Function RandomDeImagens(strPath,strDefault)
        On Error Resume Next
        Randomize Timer

        Dim ObjDeFSO, objFolder, ObjDaPasta, ObjPasta02
        Dim StrPastas, StrImagens, StrBase, StrPasta

        Const strValid = ".gif.jpg.png"

        If Right(strPath,1) <> Chr(47) Then strPath = strPath & Chr(47)
       
        StrBase = Server.MapPath(strPath)
        Set ObjDeFSO = Server.CreateObject("Scripting.FileSystemObject")
       
        Set objFolder = ObjDeFSO.GetFolder(StrBase)
        Set ObjDaPasta = objFolder.Files

        For Each ObjPasta02 In ObjDaPasta
          StrPasta = LCase(ObjPasta02.Name)
          If Instr(strValid,Right(StrPasta,4)) Then
                StrPastas = StrPastas & StrPasta & VbTab
          End If
        Next

        StrImagens = Split(StrPastas,VbTab)
       
        If UBound(StrImagens) > 1 Then
          RandomDeImagens = strPath & StrImagens(Int(Rnd(1)*UBound(StrImagens)))
        Else
          RandomDeImagens = strDefault
        End If

  End Function
%>

</head>
<body>
<div align="center">
<center>
<table border="1" bordercolor="#000000">
  <tr>
        <td bgcolor="#ffffff">
          <!-- a pasta developercenter é relacionanda a sua pasta principal -->
          <img src="<%=RandomDeImagens("images/","/developercenter/images/default.gif")%>">
        </td>
  </tr>
</table>
</center>
</div>
</body>
</html>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Visitante
Responder

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Processando...
Entre para seguir isso  

×
×
  • Criar Novo...