Je suis encore nouveau à HTA, et je cherche à ajouter un avertissement quand aucune case à cocher n'est sélectionnée et quand aucune case n'est cochée, il supprime le MsgBox actuel qui dit que toutes les cases à cocher sont traités.HTA: Afficher MsgBox lorsque toutes les cases sont décochées
Les MsgBox actuels seront remplacés par une ligne objShell.Run (robocopy).
Je sais que mon code est probablement un peu basique, donc les suggestions pour le rendre plus efficace sont les bienvenues.
<html>
<head>
<title>Sync Tool</title>
<HTA:APPLICATION
APPLICATIONNAME="Sync Tool"
ID="SyncTool"
VERSION="1.0.0"
BORDER="dialog"
MAXIMIZEBUTTON="no"
MINIMIZEBUTTON="no"
SCROLL="no"
SINGLEINSTANCE="yes"
CONTEXTMENU="no"
SELECTION="no"/>
</head>
<script language="VBScript">
Set objShell = CreateObject("Wscript.Shell")
Sub Window_OnLoad
Dim width,height
width=330
height=310
self.ResizeTo width,height
self.MoveTo (screen.AvailWidth-width)/2,(screen.AvailHeight-height)/2
End Sub
Sub OnClickButtonSyncNow()
' Box A
If BoxAA.checked Then
MsgBox "BoxAA"
Else
'Do nothing
End If
If BoxAB.checked Then
MsgBox "BoxAB"
Else
'Do nothing
End If
If BoxAC.checked Then
MsgBox "BoxAC"
Else
'Do nothing
End If
If BoxAD.checked Then
MsgBox "BoxAD"
Else
'Do nothing
End If
If BoxAE.checked Then
MsgBox "BoxAE"
Else
'Do nothing
End If
' Box B
If BoxBA.checked Then
MsgBox "BoxBA"
Else
'Do nothing
End If
If BoxBB.checked Then
MsgBox "BoxBB"
Else
'Do nothing
End If
If BoxBC.checked Then
MsgBox "BoxBC"
Else
'Do nothing
End If
If BoxBD.checked Then
MsgBox "BoxBD"
Else
'Do nothing
End If
If BoxBE.checked Then
MsgBox "BoxBE"
Else
'Do nothing
End If
MsgBox "All checkboxes are processed"
End Sub
Sub ExitTool()
window.close()
End Sub
</script>
<body bgcolor="firebrick">
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg th{font-family:Arial, sans-serif; font-size:14px; font-weight:normal; padding-top:0px ;padding-right:20px; padding-bottom:0px; padding-left:0px ;border-style:solid; border-width:0px; overflow:hidden; word-break:normal;}
.tg td{font-family:Arial, sans-serif; font-size:14px; padding-top:5px ;padding-right:10px; padding-bottom:0px; padding-left:0px ;border-style:solid; border-width:0px; overflow:hidden; word-break:normal;}
.tg .tg-header{color:#FFFB00; font-size:22px; font-weight:bold; font-family:Verdana, Geneva, sans-serif !important;}
.tg .tg-text{color:white; font-family:Verdana, Geneva, sans-serif !important; vertical-align:top}
.button {height:50px; width:136px; font-weight:bold; background-color:#555555; border: 2px solid #FFFB00; color:white; text-align:center; text-decoration:none; display:inline-block; font-size:16px;}
</style>
<table class="tg">
<tr>
<th class="tg-header">Box A</th>
<th class="tg-header">Box B</th>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="AA">AA</td>
<td class="tg-text"><input type="checkbox" name="BA">BA</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="AB">AB</td>
<td class="tg-text"><input type="checkbox" name="BB">BB</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="AC">AC</td>
<td class="tg-text"><input type="checkbox" name="BC">BC</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="AD">AD</td>
<td class="tg-text"><input type="checkbox" name="BD">BD</td>
</tr>
<tr>
<td class="tg-text"><input type="checkbox" name="AE">AE</td>
<td class="tg-text"><input type="checkbox" name="BE">BE</td>
</tr>
</table>
<br>
<input type="button" class="button" name="SyncNow" id="SyncNow" value="Sync Now" onclick="OnClickButtonSyncNow">
<input type="button" class="button" name="Exit" id="Exit" value="Exit" onclick="ExitTool">
</body>
</html>
Cela fonctionne parfaitement pour mon exemple donné. Mais que se passe-t-il si j'ai besoin de changer la valeur de 'name =' en quelque chose de différent? Données ceci et données cela. Je suis un peu confus sur le fonctionnement de 'document.getElementById (n)' car il n'y a pas de 'id = 'dans ma partie html. – WatskeBart