Hi guys
I have been trying to figure this out for a couple of days now. I am trying to make fancy radio buttons but dynamically using VBScript. I don't want to use JavaScript.
I am actually writing an HTA and want this functionality. I have attached the code and put it below. I get it as far as displaying a picture in place of the radio button but nothing happens when I click on it.
<html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
APPLICATIONNAME="My HTML application"
ID="MyHTMLapplication"
SCROLL="no"
INNERBORDER="no"
VERSION="1.0"
/>
<style type="text/css">
<!--
.radEC {
padding: 0 0 0 0;
background: url(radioEC.png) no-repeat;
width: 15px;
height: 15px;
}
.radEU {
padding: 0 0 0 0;
background: url(radioEU.png) no-repeat;
width: 15px;
height: 15px;
}
.radDC {
padding: 0 0 0 0;
background: url(radioDC.png) no-repeat;
width: 15px;
height: 15px;
}
.radDU {
padding: 0 0 0 0;
background: url(radioDU.png) no-repeat;
width: 15px;
height: 15px;
}
input.styled {
display: none;
}
-->
</style>
</head>
<script language="VBScript">
Sub Window_OnLoad
subInit
End Sub
Sub subInit
Dim inputs, span(), a
Set inputs = document.getElementsByTagName("input")
a = -1
For Each rad In inputs
If rad.type = "radio" And rad.className = "styled" Then
a = a + 1
ReDim Preserve span(a)
Set span(a) = document.createElement("span")
span(a).id = "rad" & a
If rad.Disabled = True Then
If rad.Checked = True Then
span(a).className = "radDC"
Else
span(a).className = "radDU"
End If
Else
If rad.Checked = True Then
span(a).className = "radEC"
Else
span(a).className = "radEU"
End If
End If
rad.parentNode.insertBefore span(a),(rad)
span(a).onClick = Chr(34) & "funClear'"& rad.name & "','" & span(a).id & "','" & a & "'" & Chr(34)
End If
Next
End Sub
Function funClear(rad, span, value)
Dim radio
Set objRad = document.getElementByID("rad")
Set objSpan = document.getElementByID("span")
For Each radio In objRad
If radio.checked And radio.value = value Then
objSpan.className = "radDU"
radio.checked = False
Else
objSpan.className = "radDC"
radio.checked = True
End If
Next
End Function
Sub subTest
MsgBox "Hello"
End Sub
</script>
<body bgcolor="white">
<!--Add your controls here-->
<input type="textbox" name="txbTest1" />
<input type="radio" name="radTest1" value="1" class="styled" />
<br />
<span id="testSpan" onClick="subTest">Test</span>
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>
Bookmarks