Page 1 of 1
Require Checkbox to be checked
Posted: Wed Apr 22, 2009 9:18 am
by jwestan
Anyone have any suggestions on how to require a checkbox to be check by the user before checking the next check box?
I have a series of steps that the user must follow, some using buttons with functions behind them in order to complete an entire process.
I would like to be able to require the previous step to be completed before the next step is started. As well as be able to change the color and text of a span or something simular to indicate visually that the step was completed.
For example:
Task Result
Step 1 (checkbox) Complete (color green)
Step 2 (checkbox) Not Complete (color red)
Step 3 (Checkbox) Button Not Complete (color red)
Also would it be possible when a button was selected and the process complete to check the checkbox automatically?
Thanks
Require Checkbox to be checked
Posted: Wed Apr 22, 2009 9:34 am
by jvierra
Disanble all boxes except first to start with tehn enable each one in teh "onchange" event of the current check box.
chkbox.checked = true
jvierra2009-04-22 16:36:07
Require Checkbox to be checked
Posted: Thu Apr 23, 2009 2:02 am
by jwestan
I have modifed the code to have a span that would change after the checkbox was clicked but am receiving a syntax error on line 9. I think this is because the element <span> does not have an element.value.
Is there another way to accomplish this?
<html> <head> <title>My HTML Application</title> <script language="vbscript"> Sub Doit(element) elid = element.value + 1 Set box = document.getElementById("box" & elid ) box.disabled = False Set chSpan = document.getElementById("CB" & elid) chSpan.innerHTML = <span style="background-color: Green"><font size= "2" color="White"><B>Complete</B></font> End Sub </script> </head> <body> <table> <tr> <td><span id="CB1" style="background-color: RED"><font size= "2" color="White"><B />Not Complete</span></td> <td><input id="box1" type="checkbox" onclick="doit(me)" value="1"/></td> </tr> <tr> <td><span id="CB2" style="background-color: RED"><font size= "2" color="White"><B />Not Complete</span></td> <td><input id="box2" type="checkbox" onclick="doit(me)" value="2" disabled="true" /></td> </tr> <tr> <td><span id="CB3" style="background-color: RED"><font size= "2" color="White"><B />Not Complete</span></td> <td><input id="box3" type="checkbox" onclick="doit(me)" value="3" disabled="true"/></td> </tr> <td><span id="CB4" style="background-color: RED"><font size= "2" color="White"><B />Not Complete</span></td> <td><input id="box4" type="checkbox" value="4" disabled="true"/></td> </table> </body></html>
Require Checkbox to be checked
Posted: Thu Apr 23, 2009 2:47 am
by rasimmer
This:
chSpan.innerHTML = <span style="background-color: Green"><font size= "2" color="White"><B>Complete</B></font>
needs to be:
chSpan.innerHTML = "<span style='background-color: Green'><font size= '2' color='White'><B>Complete</B></font>"rasimmer2009-04-23 09:50:39
Require Checkbox to be checked
Posted: Thu Apr 23, 2009 6:35 am
by jvierra
You are going to hav emany headaches with using text assignment to build objects. This is OK for flat output but will create issues with dynamic HTML.
Use a style sheet or you will soon not be able to see the HTML for the style. It also allows for more logical and consistent layout and flow.
Code: Select all
<html>
<head>
<title>Checkbox Text</title>
<script language="vbscript">
Sub Doit(element)
elid = "box" & (element.value + 1)
Set box = document.getElementById(elid )
If Not (box Is Nothing) Then box.disabled = False # this allow adding boxes
elid = "CB" & element.value
With document.getElementById(elid)
.innerText = "Completed!"
.style.backgroundColor="green"
End With
End Sub
</script>
<style type="text/css">
span{
font-weight: bolder;
background-color: red;
}
</style>
</head>
<body>
<table>
<tr>
<td><span id="CB1">Not Complete</span></td>
<td><input id="box1" type="checkbox" onclick="doit(me)" value="1"/></td>
</tr>
<tr>
<td><span id="CB2">Not Complete</span></td>
<td><input id="box2" type="checkbox" onclick="doit(me)" value="2" disabled="true" /></td>
</tr>
<tr>
<td><span id="CB3">Not Complete</span></td>
<td><input id="box3" type="checkbox" onclick="doit(me)" value="3" disabled="true"/></td>
</tr>
<td><span id="cb4">Not Complete</span></td>
<td><input id="box4" type="checkbox" onclick="doit(me)" value="4" disabled="true"/></td>
</table>
</body>
</html>
Require Checkbox to be checked
Posted: Thu Apr 23, 2009 7:15 am
by jvierra
I do -
I have to take care of something right now but I willbe done in about an hour. I will post it then.
Require Checkbox to be checked
Posted: Thu Apr 30, 2009 3:40 am
by jwestan
jvierra,
In trying your method for creating tables with Divs I have come across something that I can't solve.
I am trying to create a table like this. uploads/29420/CreditValidationTestTable.hta.txt
I have gotten this far:
uploads/29420/CreditValidationTestTableDIV.hta.txt
but am unable to figure out how to dynamically create my span ids, so that I can modify them with a function or sub.
I created 3 arrays for the names of the valueNames and the 3 other columns in the table.
Any suggestions?
Thanks
Require Checkbox to be checked
Posted: Thu Apr 30, 2009 6:57 am
by jwestan
I was using a span as that is what I had figured out to use and was in your example.
Yes this is true, no more checkbox. I should have started another post but since you gave me an example to create a table with Divs, I figured that might be easier but probably more confusing.
What I am actually trying to do with your example is to take two files, list out the data points and then provide a column that will state whether or not the values match.
I am still trying to get my head around your example as I am used to writing out the HTML and wanted to expand my horizons, plus save my self from all the code.
If need be I will start another post.
Require Checkbox to be checked
Posted: Thu Apr 30, 2009 8:29 am
by jvierra
To demonstrate what I am trying to say here is a simple VBS script that loads two CSV files.
Code: Select all
Set rs1 = GetData( "select * from data1.csv" )
Dumper rs1
Set rs2 = GetData( "select * from data2.csv" )
Dumper rs2
Function Dumper( rs )
With rs
For Each f In .Fields
WScript.StdOut.Write f.Name & vbTab
Next
WScript.StdOut.WriteLine
While Not .EOF
For Each f In .Fields
If Not IsNull(f.Value) Then
WScript.StdOut.Write f.Value & vbTab
Else
WScript.StdOut.Write "" & vbTab
End If
Next
WScript.StdOut.WriteLine
.MoveNext
Wend
End With
End Function
Function GetData( sQuery )
Dim conn,rs
Set conn = CreateObject("ADODB.Connection")
conn.ConnectionString = "Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=."
conn.Open
Set rs = conn.Execute(sQuery)
Set GetData = rs
End Function
This code will quickly load any two CSV files into two recordsets.
Next I will show you how to easily join them.
PS: The "Dumper" function is just to show that the recordsets are loaded and can be enumerated.
jvierra2009-04-30 15:33:46
Require Checkbox to be checked
Posted: Thu Apr 30, 2009 8:46 am
by jvierra
Yes - if you need to run your scripts accross all platforms then VBScritp may be a better choice. It is possible to deploy PowerShell through Group Policy so lack of PS is not a big issue. If you have W2K platforms then you are stuck with VBScript. (Of course W2K is obsolete and OUt-of support. I still have one client with three W2K TS servers.)
If you run many SQL reports agfainsts amny tables/databases then I highly recommend moving to Report Server as it is much easier to maintain and program.
Queries should always be defined on the database servers even when they may be "cross-database" queries. This is easier to mantain and performs better overall.
We regularly have done queries with 6, 10 or even 20 tables on SQLServer, Oracle, INformix and DB2. Always works better on backend.
For information integrity I am a big believer in haveing all information extracts done by DBAs as they are the keepers of the "system of record" and should always know when the information is changing.
For admin reports HTAs are OK. I prefer data dumps that can be formatted in Excel. I also prefer using web pages or Report Server. to distribute the reports as these are easier to maintain and secure.
The web servers give us way more power. With the Visual Studio Express products we can allow any admin to build web pages for free.
I always think of script as the way to perform changes to a system and do not see it as a tool for reporting as much as others do.