|
| |
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
Autopopulate Checkbox in DRW - 10/2/2007 11:58:59
I have a SQL database table which I would like to use in a form. In particular i want to be able to automatically check the box if a field has a value of 1 in it. I have attempted it with the following code that unfortunately doesn't work. <input type="checkbox" <%If FP_FieldVal(fp_rs,"REJOIN_DOMAIN")="1" then%>checked<%end if%> name="REJOIN_DOMAIN" value="1">
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:14:35
quote:
ORIGINAL: JohnH I have a SQL database table which I would like to use in a form. In particular i want to be able to automatically check the box if a field has a value of 1 in it. I have attempted it with the following code that unfortunately doesn't work. <input type="checkbox" <%If FP_FieldVal(fp_rs,"REJOIN_DOMAIN")="1" then%>checked<%end if%> name="REJOIN_DOMAIN" value="1"> So what happened? Is the checkbox always checked?
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:20:49
Hi William. No, it remains un-checked even if there is a 1 in the database.
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:28:56
Try change to this: <input type="checkbox" <%If FP_FieldVal(fp_rs,"REJOIN_DOMAIN")=1 then Response.Write " checked=""checked"""%><%end if%> name="REJOIN_DOMAIN" value="1">
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:32:20
I now get the following error: Error Type: Microsoft VBScript compilation (0x800A0400) Expected statement /admin/pcbuild/pc_build_amend.asp, line 122
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:34:52
quote:
ORIGINAL: JohnH I now get the following error: Error Type: Microsoft VBScript compilation (0x800A0400) Expected statement /admin/pcbuild/pc_build_amend.asp, line 122 Usual troubleshooting procedure - need to see that particular section of code and preferably point out where is line 122
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:37:26
Here you go, thanks for your help. Line 122 is the code you provided. <html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>PC Build</title>
</head>
<body>
<table border="0" width="100%" id="table1" style="border-collapse: collapse" background="../../images/bground.jpg">
<tr>
<td>
<p align="left"><b><font face="Tahoma" size="4" color="#8B1919">PC Build</font></b></td>
<td>
<p align="right"><i><font face="Cooper Black" size="5" color="#FFFFFF">
HYDREX </font></i></td>
</tr>
</table>
<form method="POST" action="insert.asp">
<!--#include file="../../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<% end if %>
<%
fp_sQry="SELECT * FROM PCBUILD WHERE RECORD_ID='::RECORD_ID::'"
fp_sDefault=""
fp_sNoRecords="<tr><td colspan=32 align=""LEFT"" width=""100%"">No records returned.</td></tr>"
fp_sDataConn="IntranetDB"
fp_iMaxRecords=0
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=True
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes=""
fp_iDisplayCols=32
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../_fpclass/fpdbrgn1.inc"-->
<table border="1" width="54%" id="table2" style="border-collapse: collapse" bordercolor="#FFFFFF">
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">User</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="PCUSER" size="43" value="<%=FP_Field(fp_rs,"PCUSER")%>"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Location</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="LOCATION" size="43" value="<%=FP_Field(fp_rs,"LOCATION")%>"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Build Date</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="BUILD_DATE" size="22" value="<%=FP_Field(fp_rs,"BUILD_DATE")%>">
<font face="Tahoma" size="2">(dd/mm/yyyy)</font></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Built By</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="BUILT_BY" size="43" value="<%=FP_Field(fp_rs,"BUILT_BY")%>"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">New Build</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="checkbox" name="NEW_BUILD" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Machine Type</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<select size="1" name="MACHINE_TYPE">
<option>Desktop</option>
<option>Notebook</option>
<option>PDA</option>
<option>Server</option>
</select></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Service Tag</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="SERVICE_TAG" size="43" value="<%=FP_Field(fp_rs,"SERVICE_TAG")%>"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">PC ID</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="PC_NAME" size="22" value="<%=FP_Field(fp_rs,"PC_NAME")%>"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Previous Owner</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<input type="text" name="PREVIOUS_OWNER" size="43" value="<%=FP_Field(fp_rs,"PREVIOUS_OWNER")%>"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Operating System</font></b></td>
<td bgcolor="#D4AAAB" colspan="3">
<select size="1" name="OPERATING_SYSTEM">
<option>Windows 2000 Professional</option>
<option>Windows XP</option>
<option>Windows Vista</option>
</select></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Rejoin Domain</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" <%If FP_FieldVal(fp_rs,"REJOIN_DOMAIN")=1 then Response.Write " checked=""checked"""%><%end if%> name="REJOIN_DOMAIN" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Update Vscan</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="UPDATE_VSCAN" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">System Locales to UK</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="SYSTEM_LOCALES_TO_UK" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Remove Other Virus
Software</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="REMOVE_OTHER_VIRUS" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Disable Windows
Security</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="DISABLE_WINDOWS_SECURITY" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Invu Client</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="INVU_CLIENT" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Local Password Set</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="LOCAL_PASSWORD_SET" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">PC User as Local Admin</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="PCUSER_TO_LOCAL_ADMIN" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Windows Classic</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="WINDOWS_CLASSIC" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Check for PST files</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="CHECK_FOR_PST_FILES" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Customise Desktop</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="CUSTOMISE_DESKTOP" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Icons in All Users
Profile</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="ICONS_TO_ALL_USERS" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Screen Resolution</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="SCREEN_RESOLUTION" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Create New User Profile</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="CREATE_NEW_USER_PROFILE" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Winzip</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="WINZIP" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Un-tick Outlook Cache
Option</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="OUTLOOK_CACHE" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Great Plains</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="GREAT_PLAINS" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Remove Gold</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="REMOVE_GOLD" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">InspHire Client</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="INSPHIRE_CLIENT" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Add Details to
Inventory</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="ADD_DETAILS_TO_INVENTORY" value="1"></td>
</tr>
<tr>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Vscan</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="VSCAN" value="1"></td>
<td bgcolor="#8B1919" width="22%"><b>
<font face="Tahoma" size="2" color="#FFFFFF">Adobe Acrobat</font></b></td>
<td bgcolor="#D4AAAB" width="2%">
<input type="checkbox" name="ADOBE_ACROBAT" value="1"></td>
</tr>
</table>
<!--#include file="../../_fpclass/fpdbrgn2.inc"-->
<p align="left"><input type="submit" value="Update" name="B1"></p>
</form>
</body>
</html>
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:39:47
Is RECORD_ID numeric? if it is then remove the single quote from '::RECORD_ID::'
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:41:00
I have done that but still get the same error.
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 12:49:27
The field REJOIN_DOMAIN is a boolean right?
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
rdouglass
Posts: 9280 From: Biddeford, ME USA Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 15:34:09
If it is SQL Server and a TrueFalse/YesNo/Boolean field, try using -1 and 0.
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/2/2007 22:30:23
quote:
ORIGINAL: JohnH I have done that but still get the same error. Can you give a screenshot of the output in the browser?
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 0:33:41
quote:
ORIGINAL: JohnH Here you go, thanks for your help. Line 122 is the code you provided. <input type="checkbox" <%If FP_FieldVal(fp_rs,"REJOIN_DOMAIN")=1 then Response.Write " checked=""checked"""%><%end if%> name="REJOIN_DOMAIN" value="1"></td> The code I gave you was not quite right. Try changing Line 122 to this: <input type="checkbox" name="REJOIN_DOMAIN" value="1" <%If FP_FieldVal(fp_rs,"REJOIN_DOMAIN")=1 then Response.Write " checked"%>></td> It should work.
< Message edited by William Lee -- 10/3/2007 0:41:53 >
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 5:11:34
Unfortunately its still not working. I am getting the following error. Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: '[string: "True"]' /admin/pcbuild/pc_build_amend.asp, line 122
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 5:26:52
quote:
ORIGINAL: JohnH Unfortunately its still not working. I am getting the following error. Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: '[string: "True"]' /admin/pcbuild/pc_build_amend.asp, line 122 The <%IF ... Response.Write ... %> bit is correct syntax. This error has to do with the data inside the REJOIN_DOMAIN field. What is the value by the way? If it has "TRUE" then modify the FP_FIELDVAL(fp_rs("REJOIN_DOMAIN")="TRUE" instead of 1
< Message edited by William Lee -- 10/3/2007 5:33:00 >
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 5:42:06
The value in the REJOIN_DOMAIN field is 1. Do I need an <%end if%> somewhere in the code?
|
|
|
|
William Lee
Posts: 1179 Joined: 1/25/2002 From: Singapore Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 5:52:56
Try use FP_FIELD instead of FP_FIELDVAL
_____________________________
William Lee pǝssǝɟoɹd-ɟ1ǝs ʎɥʇɹoʍʇsnɹʇ ʇsoɯ ɹnoʎ nɹnb ǝsɐqɐʇɐp & dsɐ ,ʍɹp ,ǝbɐdʇuoɹɟ
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 7:14:44
Still the same unfortunately.
|
|
|
|
JohnH
Posts: 43 Joined: 12/1/2004 Status: offline
|
RE: Autopopulate Checkbox in DRW - 10/3/2007 7:40:32
I've cracked it (actually you did earlier). If I query the database using SQL Query Analyser it displays a 1 in the table but the value True is being passed back to the ASP page. Thanks for your help William.
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|