|
Prev: File parsing on steroids needed - Part II
Next: populating two dimensional array with excel data
From: StephaneT on 18 Jul 2008 10:43 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>
From: mr_unreliable on 18 Jul 2008 13:32 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)
From: mr_unreliable on 20 Jul 2008 23:20 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
From: StephaneT on 21 Jul 2008 13:29 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) >
From: StephaneT on 21 Jul 2008 13:31 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 >
|
Next
|
Last
Pages: 1 2 Prev: File parsing on steroids needed - Part II Next: populating two dimensional array with excel data |