Print Page | Close Window

Tick Boxes

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=17118
Printed Date: 29 March 2026 at 9:41pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Tick Boxes
Posted By: sccs
Subject: Tick Boxes
Date Posted: 02 November 2005 at 11:39am
I have had to design a page for students at our school. They are asked to submit stories etc for the website. I have set it up so I have to authorise the information before it goes live. This works fine but for one small problem. My admin page shows all the submitted information. Each one has a tick box next to it. Default is False not to show. If I tick the box the information is shown on the site. Great so far. Now when I go back to my admin page, any items that have been authorised to be shown do not have a tick in the box. All boxes are empty so I have no way of knowing which one is showing. I am already using the WebWiz Guestbook on our site but I don't want to use this for this kind of form. Thanks



Replies:
Posted By: michael
Date Posted: 02 November 2005 at 12:14pm

This depends how the authorization is stored. Do you store a true/false in a database on whether to display the stuff? If so you need to make a connection on the page load and iterate for each story whether it has been approved and set the checkbox accordingly



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: theSCIENTIST
Date Posted: 02 November 2005 at 3:31pm
Yes, like michael said, store the state of the checkbox in the db, that info should be submited along with the rest.

Then, when you read back, don't forget to read the status of the check box, and on rendering the list you have to do a [ If chkStatus from DB = true then ] ... inside the check box to render the check box and assign the property [checked] to it, so it shows the check box ticked up accordingly.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: sccs
Date Posted: 04 November 2005 at 4:31am
It is stored as a True/False in the database. Not to sure on how to add the If chkStatus. This is the line of code for the check box:
 
<input name="checkbox" type="checkbox" value="true" accept="<%=(STORY.Fields.Item("Show").Value)%>">
 
Could you go in to a bit more detail. Sorry.
Thanks for your help.


Posted By: theSCIENTIST
Date Posted: 04 November 2005 at 5:13am
Ok, you have an ACCEPT property on the INPUT that you might not need, anyway, here's how you do it:

This is when you are reading from the database:


Dim checkED
checkED = ""

'// Here goes you database conn and recordset
'// Then you start rendering


If RS("fld_chkStatus") Then checkED = "checked"

<input name="checkbox" type="checkbox" value="true" <%= checkED %>/>

Note that RS("fld_chkStatus") should be changed to the db field you are storing the true/flase state of the checkbox.

This should work, let me know.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: sccs
Date Posted: 04 November 2005 at 6:36am
Hi Thanks for that. Still having a problem. I changed the code as you said. but it still shows no ticks. It now reads:
 
<If RS("fld_Show") Then checkED = "checked">
                &nbs p;                &n bsp;  <input name="checkbox" type="checkbox" value="true" <%= checkED %>/>
 
 
What does the RS stand for?
The url to the page is http://www.History_Comment_Admin.asp - http://www.History_Comment_Admin.asp
 
It's only a test page.


Posted By: theSCIENTIST
Date Posted: 04 November 2005 at 7:08am
RS stands for RecordSet, but you have to change it to what you call it in your declarations, such as:


Set RS = Server.CreateObject("ADODB.Recordset")


Look in your code where you have this declaration and change RS in my code to whatever you have in yours.

-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com


Posted By: sccs
Date Posted: 04 November 2005 at 7:47am
Hi. What am I doing wrong.
 
Here is the code:
 
 
First bit
 
 
<%
Dim STORY
Dim STORY_numRows
Dim checkED
checkED = ""
Set STORY = Server.CreateObject("ADODB.Recordset")
STORY.ActiveConnection = MM_consccs_STRING
STORY.Source = "SELECT *  FROM HistoryOfSCCS  ORDER BY SubmitDate DESC"
STORY.CursorType = 0
STORY.CursorLocation = 2
STORY.LockType = 1
STORY.Open()
STORY_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
STORY_numRows = STORY_numRows + Repeat1__numRows
%>
 
 
Bit for checkbox:
 
<If STORY("fld_Show") = "True" Then checkbox = "checkED">
                &nbs p;                &n bsp;  <input name="checkbox" type="checkbox" value="true" <%= checkED %>/>
 
 
 
I am sure it's something very simple but I am unable to see it.
 
Thanks for all your help.
Andy


Posted By: Gullanian
Date Posted: 04 November 2005 at 9:03am
Firstly if fld_show is a boolean variable in the database, you shoudln't compare it as a string,

IE story("fld_show") = True NOT story("fld_show") = "True"

Also, change the line to:

<input name="checkbox" type="checkbox" value="true" checked="<%= checkbox %>"/>


Posted By: sccs
Date Posted: 04 November 2005 at 9:20am
I have sorted it out. It's now working fine.
All I have to do now is work out how to receive an e-mail when someone adds a comment. I am using formmail. I don't know if you have seen this. It's not bad. The only thing is I can't get it to send me an e-mail when someone adds a comment. It's designed for a contact form with hidden fields on the form and redirects the page to the formmail and then to a thankyou page.
 
Sorry for being a pain.
Thanks for all your help.
 
This is formmail:
 
 
<%@ Language = vbscript%>
<%option explicit %>
<%server.scripttimeout = 600 %>
<%
'declare variables

Dim strFrom, strTo, strSubject, strBody
Dim objMessage, objConfig, strServer, intPort
Dim recipient, redirect, subject, realname, email, required, strEmail1, strEmail2
Dim referer, url, url_verified, icounter, query, iloop, query2, query3, i, agree, validation, error0, error0ok
'############################## CONFIGURATION VARIABLES ####################################
'These are the only lines you will need to change
'--------------------------------------------------------------------------------------------------- -
strServer = "smtp.sccs.camden.sch.uk" 'set which smtp server will be used to send the email. enter ip address or domain name. eg: "xxx.xxx.xxx.xxx" or "smtp.your-domain.com"
intPort = 25 'set the smtp port to be used when sending mail (by default port 25 is used)
'Referrer's Array is defined here. Enter the valid domains which may use this script.
url = Array(" http://www.sccs.camden.sch.uk"Set - www.sccs.camden.sch.uk")'Set which urls that will be accepted. http://xxxxx/ - http://xxxxx/
 'Seperate multiple domains by commas
 'eg: url= Array("www.your-domain.com","your-domain.com","www.my-domain.com")
 'computer names can be used instead of domains if this script is being run locally
 'eg: url = Array("computername")
'
'information type and CDOSYS constants
'--------------------------------------------------------------------------------------------------- -
%>
<!--METADATA TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib"
UUID="00000205-0000-0010-8000-00AA006D2EA4"
NAME="ADODB Type Library" -->
<%
'--------------------------------------------------------------------------------------------------- -
'retrieved default fields
'--------------------------------------------------------------------------------------------------- -
recipient = request("recipient")
redirect = request("redirect")
subject = request("subject")
email = request("email")
required = request("required")
if required = "" then
 required = "recipient,subject,email,redirect"
else
 required = "recipient,subject,email,redirect," & required
end if
'--------------------------------------------------------------------------------------------------- -
'verify the referer
'--------------------------------------------------------------------------------------------------- -
referer = request.ServerVariables("HTTP_REFERER")
referer = split(referer,"/")
url_verified = "no"
for icounter = Lbound(url) to Ubound(url) '
 if referer(2) = url(icounter) then
  url_verified = "yes"
 end if
next
if not url_verified = "yes" then
 response.write("The url specified is invalid!")
 response.End
end if
'--------------------------------------------------------------------------------------------------- -
'verify the recipient(not tested)
'--------------------------------------------------------------------------------------------------- -
'trimed_referer = split(referer(2),".")'
'response.write recipient & "<br>" & referer(2) & "=" & trimed_referer(0) & "<br>"
'if trimed_referer(0) = "www" then
' if InStr(1,recipient,trimed_referer(1),1) = 0 then
'  response.write "recipient don't match the referer"
'  response.end
' end if
'else
' if InStr(1,recipient,trimed_referer(0),1) = 0 then
'  response.write "recipient don't match the referer"
'  response.end
' end if
'end if
'--------------------------------------------------------------------------------------------------- -
'retrieve form contents and create email fields
'--------------------------------------------------------------------------------------------------- -
query = Request.ServerVariables("QUERY_STRING")
query = split(query,"&")
query3 = split(required,",")
 For iLoop = Lbound(query) to UBound(query)
  query2 = split(query(iloop),"=")
 
'--------------------------------------------------------------------------------------------------- -
'form validation, checks required fields are not null
'--------------------------------------------------------------------------------------------------- -
  for i = LBound(query3) to UBound(query3)
   if query3(i) = query2(0) then
    if query2(1) = "" then
     response.write ("you must enter a valid ") & query2(0)
     response.end
    end if
   end if
   
   'if query2(0) = "agree" then
    'if query2(1) <> "on" or query2(1) = "" then
    ' response.write("You must agree to terms and conditions to enable Formmailv1.3 to execute!")
    'response.end
    'end if
   'end if
   
'--------------------------------------------------------------------------------------------------- -
'form validation, checks a valid email address has been specified
'--------------------------------------------------------------------------------------------------- -   
   if query2(0) = "email" then
    trim(query2(0))
    if len(query2(1))<8 then
     response.Write("You must specify a valid ") & query2(0)
     response.end
    end if
    if instr(query2(1),"@")=0 and instr(query2(1),".")=0 then
     response.write query2(1)
     response.Write("You must specify a valid ") & query2(0)
     response.end
    end if
    strEmail1 = split(query2(1),"@")
    if len(strEmail1(1))<3 then
     response.Write("You must specify a valid ") & query2(0)
     response.end
    end if
    strEmail2 = split(strEmail1(1),".")
    if len(strEmail2(0))<3 then
     response.Write("You must specify a valid ") & query2(0)
     response.end
    end if
    if len(strEmail2(1))<2 then
     response.Write("You must specify a valid ") & query2(0)
     response.end
    end if


Posted By: michael
Date Posted: 04 November 2005 at 2:52pm
add a javascript event on the checkbox tick to submit the form

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: sccs
Date Posted: 08 November 2005 at 5:38am
Thanks for your help. I managed to sort it out. Works fine now.
Thanks.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net