Accueil > > > TOOLS HTML
TOOLS HTML
Information sur la source
Description
C'est un petit exemple d'utilisation d'objet en ASP.
Le but étant de se simplifier la vie en ayant des objets formulaires prêts à l'emploi et de pouvoir facilement changer l'aspect d'un site sans se retaper tout le html.
Le zip comprend un fichier test qui utilise ces objets
Happy coding !
Source
- <%
- 'Toutes licences accordées à zappy
-
- class typeItem
- public key
- public caption
- end class
-
- class optiComboBox
- public SelectName
-
- private myItem()
- private ItemCount
- public activeKey
-
-
- public function AddItem(key, caption)
- redim preserve myItem(ItemCount)
- set myItem(ItemCount) = new typeItem
- myItem(ItemCount).key = key
- myItem(ItemCount).caption = caption
- ItemCount = ItemCount + 1
- end function
-
- public sub Clear()
- erase MyItem
- ItemCount = 0
- end sub
-
- public function getStringHTML()
- dim strBuffer, i
- if ItemCount > 0 then
- for i=0 to (ItemCount - 1) step 1
- strBuffer = strBuffer & "<option value=" & chr(34) & myItem(i).key & chr(34)
- if myItem(i).key = activeKey then
- strBuffer = strBuffer & " selected"
- end if
- strBuffer = strBuffer & ">" & myItem(i).caption & "</option>" & VbCrLf
- next
- strBuffer = "<select name=" & chr(34) & SelectName & chr(34) & ">" & VbCrLf & strBuffer & "</select>"
- end if
- getStringHTML = strBuffer
- end function
- end class
-
- class optiDateComboBox
- public intMinYear
- public intMaxYear
- public dtValue
- public strName
-
- private sub class_initialize()
- intMinYear = year(now()) - 100
- intMaxYear = year(now()) + 1
- end sub
-
- public function SetNewValue(strDay, strMonth, strYear)
- dim strBuffer
- strBuffer = strDay & "/" & strMonth & "/" & strYear
- if isdate(strbuffer) then
- dtValue = CDate(strBuffer)
- SetNewValue = true
- else
- SetNewValue = false
- end if
- end function
-
- public function getStringHTML()
- Dim strBuffer
- Dim i
-
- If intMinYear > intMaxYear Then Exit Function
- if not isdate(dtValue) then dtValue = #01/01/1950#
- 'Les jours
- strBuffer = "<select name=" & Chr(34) & strName & "jj" & Chr(34) & ">" & VbCrLf
- For i = 1 To 31 Step 1
- strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
- If CInt(Day(dtValue)) = i Then strBuffer = strBuffer & " selected"
- strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
- Next
- strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
-
- 'Les mois
- strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "mm" & Chr(34) & ">" & VbCrLf
- For i = 1 To 12 Step 1
- strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
- If CInt(Month(dtValue)) = i Then strBuffer = strBuffer & " selected"
- strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
- Next
- strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
-
-
- 'Les annees
- strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "aa" & Chr(34) & ">" & VbCrLf
- For i = intMinYear To intMaxYear Step 1
- strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
- If CInt(Year(dtValue)) = i Then strBuffer = strBuffer & " selected"
- strBuffer = strBuffer & ">" & CStringNombre(i,4) & "</option>" & VbCrLf
- Next
- strBuffer = strBuffer & "</select>" & VbCrLf
-
- getStringHTML = strBuffer
- end function
- end class
-
- class optiRadioBox
- public RadioName
- private myItem()
- private ItemCount
- public activeKey
-
-
- public function AddItem(key, caption)
- redim preserve myItem(ItemCount)
- set myItem(ItemCount) = new typeItem
- myItem(ItemCount).key = key
- myItem(ItemCount).caption = caption
- ItemCount = ItemCount + 1
- end function
-
- public sub Clear()
- erase MyItem
- ItemCount = 0
- end sub
-
- public property get CountItem()
- CountItem = ItemCount
- end property
-
- public function GetStringHTML(itemKey)
- for i = 0 to ItemCount - 1 step 1
- if myItem(i).key = itemKey then
- GetStringHTML = GetStringHTMLItem(i)
- exit for
- end if
- next
- end function
- public function GetStringHTMLItem(indexItem)
- dim strBuffer
- strBuffer = "<input type=""radio"" name=""" & RadioName & """ value=""" & cstr(myItem(indexItem).key) & """"
- if myItem(indexItem).key = activeKey then
- strBuffer = strBuffer & " CHECKED"
- end if
- GetStringHTMLItem = strBuffer & ">" & myItem(indexItem).caption
- end function
- end class
-
-
- public function CStringNombre(value, nbrChiffre)
- if len(cstr(value)) < nbrChiffre then
- CStringNombre = string(nbrChiffre - len(cstr(value)),"0") & cstr(value)
- else
- CStringNombre = cstr(value)
- end if
- end function
-
- function opt_processArray(inArray, inStringRow)
-
- returnString = ""
- bufferString = ""
- on error resume next
-
- nbrRow = ubound(inArray) - lbound(inArray)
- nbrField = ubound(inArray, 2) - lbound(inArray, 2)
- if err.number <> 0 then exit function
-
- on error goto 0
-
- for i = lbound(inArray) to ubound(inArray) step 1
- bufferString = inStringRow
- for n=lbound(inArray,2) to ubound(inArray,2) step 1
- bufferString = replace(bufferString, "{" & CStr(n) & "}",CStr(inArray(i,n)))
- next
- returnString = returnString & bufferString 'Retour charriot dans la string passée en argument !!
- next
-
- opt_processArray = returnString
- end function
- %>
<%
'Toutes licences accordées à zappy
class typeItem
public key
public caption
end class
class optiComboBox
public SelectName
private myItem()
private ItemCount
public activeKey
public function AddItem(key, caption)
redim preserve myItem(ItemCount)
set myItem(ItemCount) = new typeItem
myItem(ItemCount).key = key
myItem(ItemCount).caption = caption
ItemCount = ItemCount + 1
end function
public sub Clear()
erase MyItem
ItemCount = 0
end sub
public function getStringHTML()
dim strBuffer, i
if ItemCount > 0 then
for i=0 to (ItemCount - 1) step 1
strBuffer = strBuffer & "<option value=" & chr(34) & myItem(i).key & chr(34)
if myItem(i).key = activeKey then
strBuffer = strBuffer & " selected"
end if
strBuffer = strBuffer & ">" & myItem(i).caption & "</option>" & VbCrLf
next
strBuffer = "<select name=" & chr(34) & SelectName & chr(34) & ">" & VbCrLf & strBuffer & "</select>"
end if
getStringHTML = strBuffer
end function
end class
class optiDateComboBox
public intMinYear
public intMaxYear
public dtValue
public strName
private sub class_initialize()
intMinYear = year(now()) - 100
intMaxYear = year(now()) + 1
end sub
public function SetNewValue(strDay, strMonth, strYear)
dim strBuffer
strBuffer = strDay & "/" & strMonth & "/" & strYear
if isdate(strbuffer) then
dtValue = CDate(strBuffer)
SetNewValue = true
else
SetNewValue = false
end if
end function
public function getStringHTML()
Dim strBuffer
Dim i
If intMinYear > intMaxYear Then Exit Function
if not isdate(dtValue) then dtValue = #01/01/1950#
'Les jours
strBuffer = "<select name=" & Chr(34) & strName & "jj" & Chr(34) & ">" & VbCrLf
For i = 1 To 31 Step 1
strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
If CInt(Day(dtValue)) = i Then strBuffer = strBuffer & " selected"
strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
Next
strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
'Les mois
strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "mm" & Chr(34) & ">" & VbCrLf
For i = 1 To 12 Step 1
strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
If CInt(Month(dtValue)) = i Then strBuffer = strBuffer & " selected"
strBuffer = strBuffer & ">" & CStringNombre(i,2) & "</option>" & VbCrLf
Next
strBuffer = strBuffer & "</select>" & VbCrLf & "/" & VbCrLf
'Les annees
strBuffer = strBuffer & "<select name=" & Chr(34) & strName & "aa" & Chr(34) & ">" & VbCrLf
For i = intMinYear To intMaxYear Step 1
strBuffer = strBuffer & "<option value=" & Chr(34) & CStr(i) & Chr(34)
If CInt(Year(dtValue)) = i Then strBuffer = strBuffer & " selected"
strBuffer = strBuffer & ">" & CStringNombre(i,4) & "</option>" & VbCrLf
Next
strBuffer = strBuffer & "</select>" & VbCrLf
getStringHTML = strBuffer
end function
end class
class optiRadioBox
public RadioName
private myItem()
private ItemCount
public activeKey
public function AddItem(key, caption)
redim preserve myItem(ItemCount)
set myItem(ItemCount) = new typeItem
myItem(ItemCount).key = key
myItem(ItemCount).caption = caption
ItemCount = ItemCount + 1
end function
public sub Clear()
erase MyItem
ItemCount = 0
end sub
public property get CountItem()
CountItem = ItemCount
end property
public function GetStringHTML(itemKey)
for i = 0 to ItemCount - 1 step 1
if myItem(i).key = itemKey then
GetStringHTML = GetStringHTMLItem(i)
exit for
end if
next
end function
public function GetStringHTMLItem(indexItem)
dim strBuffer
strBuffer = "<input type=""radio"" name=""" & RadioName & """ value=""" & cstr(myItem(indexItem).key) & """"
if myItem(indexItem).key = activeKey then
strBuffer = strBuffer & " CHECKED"
end if
GetStringHTMLItem = strBuffer & ">" & myItem(indexItem).caption
end function
end class
public function CStringNombre(value, nbrChiffre)
if len(cstr(value)) < nbrChiffre then
CStringNombre = string(nbrChiffre - len(cstr(value)),"0") & cstr(value)
else
CStringNombre = cstr(value)
end if
end function
function opt_processArray(inArray, inStringRow)
returnString = ""
bufferString = ""
on error resume next
nbrRow = ubound(inArray) - lbound(inArray)
nbrField = ubound(inArray, 2) - lbound(inArray, 2)
if err.number <> 0 then exit function
on error goto 0
for i = lbound(inArray) to ubound(inArray) step 1
bufferString = inStringRow
for n=lbound(inArray,2) to ubound(inArray,2) step 1
bufferString = replace(bufferString, "{" & CStr(n) & "}",CStr(inArray(i,n)))
next
returnString = returnString & bufferString 'Retour charriot dans la string passée en argument !!
next
opt_processArray = returnString
end function
%>
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT)CSS CONTENT STATE SELECTORS (PERSONNAL DRAFT) par FREMYCOMPANY
Bonjour à tous, Je viens de publier une proposition comprenant 5 pseudo-classes pour le CSS Working Group ayant trait à l'état de chargement d'un élément (ex: IMG,VIDEO,AUDIO,OBJECT pour l'HTML.). Si le c½ur vous en dit, vous pouvez retrouver cette p...
Cliquez pour lire la suite de l'article par FREMYCOMPANY MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ?MBA : POURQUOI FAIRE ET COMMENT LE CHOISIR ? par ROMELARD Fabrice
Formation initiale Durant la formation, le découpage classique est le suivant (je donnerai les équivalences Suisse lorsque je les connaîtrais) : Ecole primaire jusqu'au Collège : Formation générale permettant d'obtenir les méthodes...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice Y'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENTY'A DES ERREURS QUI PEUVENT RENDRE LE DéVELOPPEUR VIOLENT par Aleks
Quand on a ce genre d'erreur sans log :
Et bas on a juste envie de choper le gas de Microsoft qu'a développé ça et lui foutre des baffes de Coboye ! ...
Cliquez pour lire la suite de l'article par Aleks [HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL[HYPER-V 3] PRéSENTATION DES COMMANDLETS POWERSHELL par Pierrick CATRO-BROUILLET
Avec la sortie prochaine de la Beta Consumer Preview de Windows 8, j'avais envie de revenir sur une des fonctionnalités que j'attends le plus et que, en bon geek que je suis, j'utilise déjà : Hyper-V 3 ainsi son module PowerShell.
Il y a déjà pléthor...
Cliquez pour lire la suite de l'article par Pierrick CATRO-BROUILLET IIS7 - COMPRESSION GZIPIIS7 - COMPRESSION GZIP par cyril
La compression GZIP permet d'améliorer les performances de navigation en compressant ce qu'envoie le serveur à un client. Pour comprendre comment cela fonctionne, regardons ce qu'il se passe au niveau HTTP lorsqu'un client tente d'accéder à une ress...
Cliquez pour lire la suite de l'article par cyril
Forum
SCRIPTSCRIPT par nadialadypower
Cliquez pour lire la suite par nadialadypower
Logiciels
Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning Academy System (17.1.3.0)ACADEMY SYSTEM (17.1.3.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|