My option buttons are not working! When I click on one of them. the bullet
turns grey momentarily but does not stick. I just can't figure out why! Can
someone help me!

The purpose of this script will be to enumerate files in the current folder.
Select the files and it will eventually (not yet implemented) compare files
select.

<html>
<head>
<HTA:APPLICATION
APPLICATIONNAME="Compare Files"
SCROLL="no"
SINGLEINSTANCE="no">

<script language="VBScript">
Sub GetLogs

Dim btnCompare, objForm, i, objElement


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Wscript.Shell")

Set objFolder = objFSO.GetFolder(objShell.CurrentDirectory)
Set colFiles = objFolder.Files
Set objForm1 = Document.Forms("log1")
Set objForm2 = Document.Forms("log2")
For Each objFile in colFiles
If InStr (lcase(objFile.Name),"log") Then
Set objElement=document.createElement("input")
With objElement
.type="radio"
.value=objFile.Name
.name="file1"
End With
objForm1.appendChild objElement
Set objElement=document.createElement("input")
With objElement
.type="radio"
.value=objFile.Name
.name="file2"
End With
objForm2.appendChild objElement
Set objElement=document.createTextNode(objFile.Name)
objForm1.appendChild objElement
Set objElement=document.createTextNode(objFile.Name)
objForm2.appendChild objElement
set objElement=document.createElement("br")
objForm1.appendChild objElement
set objElement=document.createElement("br")
objForm2.appendChild objElement
'set objElement=nothing

End If
Next



End Sub

Sub CompareFiles
Dim i
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objResultFile = objFSO.OpenTextFile("comparison.txt", ForWriting,
TRUE)
objResultFile.WriteLine ("test")

For i = 0 to Document.Form.Elements.Count -1
If Document.Form.Elements(i).Name = "file1" Then
If Document.Form.Elements(i).Checked Then

strFile1 = Document.Form.Elements(i).Value
objResultFile.WriteLine = strFile1
Exit For
End if
End if
Next
For i = 0 to Document.Form.Elements.Count -1
If Document.Form.Elements(i).Name = "file2" Then
If Document.Form.Elements(i).Checked Then

strFile2 = Document.Form.Elements(i).Value
objResultFile.WriteLine = strFile1
Exit For
End if
End if
Next

End Sub
</script>

</head>
<body onload="GetLogs">
<table width="100%" border>
<tr>
<td width="50%" valign="top">
<form id="log1">
</form>
</td>
<td width="50%" valign="top">
<form id="log2">
</form>
</td>
</tr>
</table>
<input id=runbutton type="button" value="Compare Files" name="runButton"
onClick="CompareFiles"><p>


</body>
</html>

Re: Dynamic Radio button in HTA will not selecting. by mr_unreliable

mr_unreliable
Fri Jul 18 12:32:32 CDT 2008

StephaneT wrote:
> My option buttons are not working!

hi StephaneT,

I can't say why your code is not working, but it
didn't work for me either.

However, I dorked around a bit, and found something
that did work for me (i.e., if I click on one of the
option buttons, it does retain the little dot):

--- <code> ---
Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
& "NAME='file1' " & "VALUE='" & CStr(objFile.Name) & "'>")
objForm1.appendChild objElement
Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
& "NAME='file2' " & "VALUE='" & CStr(objFile.Name) & "'>")
objForm2.appendChild objElement
Set objElement=document.createTextNode(objFile.Name)
objForm1.appendChild objElement
Set objElement=document.createTextNode(objFile.Name)
objForm2.appendChild objElement
set objElement=document.createElement("br")
objForm1.appendChild objElement
set objElement=document.createElement("br")
objForm2.appendChild objElement
'set objElement=nothing
--- </code> ---

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)

Re: Dynamic Radio button in HTA will not selecting. by mr_unreliable

mr_unreliable
Sun Jul 20 22:20:18 CDT 2008

mr_unreliable wrote:
> --- <code> ---
> Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> & "NAME='file1' " & "VALUE='" & CStr(objFile.Name) & "'>")
> objForm1.appendChild objElement
> Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> & "NAME='file2' " & "VALUE='" & CStr(objFile.Name) & "'>")
> objForm2.appendChild objElement
> Set objElement=document.createTextNode(objFile.Name)
> objForm1.appendChild objElement
> Set objElement=document.createTextNode(objFile.Name)
> objForm2.appendChild objElement
> set objElement=document.createElement("br")
> objForm1.appendChild objElement
> set objElement=document.createElement("br")
> objForm2.appendChild objElement
> 'set objElement=nothing
> --- </code> ---
>
> cheers, jw

After indulging in a little "code-polishing":

--- <code-polished code> ---
sHTML1 = "<INPUT TYPE='RADIO' " & "NAME='file1' " & "VALUE='" _
& objFile.Name & "'>" & objFile.Name & "</INPUT>" & "<BR>"
objForm1.insertAdjacentHTML "beforeEnd", sHTML1
sHTML2 = "<INPUT TYPE='RADIO' " & "NAME='file2' " & "VALUE='" _
& objFile.Name & "'>" & objFile.Name & "</INPUT>" & "<BR>"
objForm2.insertAdjacentHTML "beforeEnd", sHTML2
--- </code-polished code> ---

Vorsicht! Code-polishing can endanger your career.
While you spend your time code-polishing, those other
software engineers will be finishing their projects
on time, they will be getting the salary increases,
the bonuses, the stock options and the promotions.
Everybody will say "he wrote some beautiful code"
as you walk out the door holding your "pink slip".

cheers, jw

Re: Dynamic Radio button in HTA will not selecting. by stealth8888

stealth8888
Mon Jul 21 12:29:01 CDT 2008

This works great!

Thank you!

"mr_unreliable" wrote:

> StephaneT wrote:
> > My option buttons are not working!
>
> hi StephaneT,
>
> I can't say why your code is not working, but it
> didn't work for me either.
>
> However, I dorked around a bit, and found something
> that did work for me (i.e., if I click on one of the
> option buttons, it does retain the little dot):
>
> --- <code> ---
> Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> & "NAME='file1' " & "VALUE='" & CStr(objFile.Name) & "'>")
> objForm1.appendChild objElement
> Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> & "NAME='file2' " & "VALUE='" & CStr(objFile.Name) & "'>")
> objForm2.appendChild objElement
> Set objElement=document.createTextNode(objFile.Name)
> objForm1.appendChild objElement
> Set objElement=document.createTextNode(objFile.Name)
> objForm2.appendChild objElement
> set objElement=document.createElement("br")
> objForm1.appendChild objElement
> set objElement=document.createElement("br")
> objForm2.appendChild objElement
> 'set objElement=nothing
> --- </code> ---
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>

Re: Dynamic Radio button in HTA will not selecting. by stealth8888

stealth8888
Mon Jul 21 12:31:03 CDT 2008

I'm using your polished code and it works perfect.

Reading polished code is like reading a good novel!

"mr_unreliable" wrote:

> mr_unreliable wrote:
> > --- <code> ---
> > Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> > & "NAME='file1' " & "VALUE='" & CStr(objFile.Name) & "'>")
> > objForm1.appendChild objElement
> > Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> > & "NAME='file2' " & "VALUE='" & CStr(objFile.Name) & "'>")
> > objForm2.appendChild objElement
> > Set objElement=document.createTextNode(objFile.Name)
> > objForm1.appendChild objElement
> > Set objElement=document.createTextNode(objFile.Name)
> > objForm2.appendChild objElement
> > set objElement=document.createElement("br")
> > objForm1.appendChild objElement
> > set objElement=document.createElement("br")
> > objForm2.appendChild objElement
> > 'set objElement=nothing
> > --- </code> ---
> >
> > cheers, jw
>
> After indulging in a little "code-polishing":
>
> --- <code-polished code> ---
> sHTML1 = "<INPUT TYPE='RADIO' " & "NAME='file1' " & "VALUE='" _
> & objFile.Name & "'>" & objFile.Name & "</INPUT>" & "<BR>"
> objForm1.insertAdjacentHTML "beforeEnd", sHTML1
> sHTML2 = "<INPUT TYPE='RADIO' " & "NAME='file2' " & "VALUE='" _
> & objFile.Name & "'>" & objFile.Name & "</INPUT>" & "<BR>"
> objForm2.insertAdjacentHTML "beforeEnd", sHTML2
> --- </code-polished code> ---
>
> Vorsicht! Code-polishing can endanger your career.
> While you spend your time code-polishing, those other
> software engineers will be finishing their projects
> on time, they will be getting the salary increases,
> the bonuses, the stock options and the promotions.
> Everybody will say "he wrote some beautiful code"
> as you walk out the door holding your "pink slip".
>
> cheers, jw
>

Re: Dynamic Radio button in HTA will not selecting. by stealth8888

stealth8888
Mon Jul 21 12:33:00 CDT 2008

I do use IE6 and I should have mentionned this in my initiale post. I could
not try it on IE7 as we have not deployed it in our enterprise.

"Joe Fawcett" wrote:

> Adding to jw's response this was a limitation of earlier libraries, you
> couldn't create and then name an input element, it had to be done in one
> ugly step. I believe that this has been fixed in later versions of IE but it
> appears that the HTA is still using an older version, or that you don't have
> the latest version of IE.
>
> --
>
> Joe Fawcett (MVP - XML)
> http://joe.fawcett.name
>
> "mr_unreliable" <kindlyReplyToNewsgroup@notmail.com> wrote in message
> news:e3DYQsP6IHA.1204@TK2MSFTNGP04.phx.gbl...
> > StephaneT wrote:
> >> My option buttons are not working!
> >
> > hi StephaneT,
> >
> > I can't say why your code is not working, but it
> > didn't work for me either.
> >
> > However, I dorked around a bit, and found something
> > that did work for me (i.e., if I click on one of the
> > option buttons, it does retain the little dot):
> >
> > --- <code> ---
> > Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> > & "NAME='file1' " & "VALUE='" & CStr(objFile.Name) & "'>")
> > objForm1.appendChild objElement
> > Set objElement=document.createElement("<INPUT TYPE='RADIO' " _
> > & "NAME='file2' " & "VALUE='" & CStr(objFile.Name) & "'>")
> > objForm2.appendChild objElement
> > Set objElement=document.createTextNode(objFile.Name)
> > objForm1.appendChild objElement
> > Set objElement=document.createTextNode(objFile.Name)
> > objForm2.appendChild objElement
> > set objElement=document.createElement("br")
> > objForm1.appendChild objElement
> > set objElement=document.createElement("br")
> > objForm2.appendChild objElement
> > 'set objElement=nothing
> > --- </code> ---
> >
> > cheers, jw
> > ____________________________________________________________
> >
> > You got questions? WE GOT ANSWERS!!! ..(but,
> > no guarantee the answers will be applicable to the questions)
>