Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>Checkbox to manipulate Form Field

Checkbox to manipulate Form Field

werD
02-03-2005, 09:55 PM
I have written the following asp code to submit a form to a database but Im running into a problem. I have a a Checkbox on my form named "None" I would like to make it to when the checkbox is clicked it will leave out the entire line below that calls for the field "Docs" I was told that I would be better off doing this with Javascript.
Im kind of a newb to Javascript but am currently reading up Does anyone know how I would use the checkbox to eliminate the form request?
<%@Language = "VbScript"%>
<!--#include file="adovbs.inc"-->
<%
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath ("asp/db3.mdb")

Set ObjRs=Server.CreateObject("ADODB.Recordset")
ObjRs.Open "Hottopic", strConnect, adOpenKeySet,adLockOptimistic,adCmdTable
ObjRs.AddNew
'ObjRs("ID")=Request.form("ID")
ObjRs("Date_")=Request.form("Date_")
ObjRs("Control Number")=Request.form("Control Number")
ObjRs("Company Name")=Request.form("Company Name")
ObjRs("Comments")=Request.form("Comments")
ObjRs("Contact")=Request.form("Contact")
ObjRs("Docs")="<a href=http://lou1-web01/robohelp/shpsmate/shpsmate%20v3/Captains%20Log/Barbara%20Pages/Pages%20for%20FSA/" & Request.form("Docs") & ">Linked Material</a>"
ObjRs.Update
ObjRs.Close
Set ObjRs=Nothing

Response.write "<center><b>Record Added!</b></center>"
%>

WillGibson
02-03-2005, 10:04 PM
Post the frontend page please. :)

werD
02-03-2005, 10:07 PM
<html>
<head>

<style type="text/css">
<!--
.style2 {
color: #404040;
font-style: italic;
}
-->
</style></Head>
<Body>
<table bgcolor="#D4D4D4"><tr><td width="100"></td>
<Form action="hotaddnow.asp" method="post">
<tr>
<td>&nbsp;</td>
<td colspan="2"><strong>Submit Your Hot topic/Client Specific for FSA </strong></td>
<td colspan=2></td>
</tr>
<tr><td><strong>Date</strong></td>
<td><input type="text" name="date_" size="20"></td><td>
<span class="style2">format= MM/DD/YYYY </span></td><td width="179" colspan=2></td></tr>
<Tr><td><strong>Company Name</strong></td><td><input type="text" name="Company Name" size="20"></td><td width="125" align="right"><strong>Control Number</strong> </div>
</td><td><input type="text" name="Control Number" size="20"></td></tr>
<tr><td><strong>Comments</strong></td><td colspan=2><Textarea name="Comments" Rows="5" Columns="4"></Textarea></td><td></td></tr>
<tr valign="top">
<td height="67" colspan="4"></td>
</tr>
<tr><td><strong>Contact</strong></td><td><input type="text" name="Contact" size="20"></td>
<td><div align="center"><strong>Document Hyperlink</strong></div></td><td><input type="checkbox" name="none" Value="True"><input type="text" Name="Docs" size="20"></td>
</tr>

<tr><td><input type="submit" name="sub"></td>
<td></td><td colspan="2">&nbsp;</td>
</tr>
</form>
</table>
</body>
</HTML>

WillGibson
02-03-2005, 10:23 PM
If you want to keep using an HTTP POST (i.e. method="post") then keep the checkbox check in the backend page. You will not be able to do an HTTP POST with Javascript.

If you want to change things and use HTTP GET (i.e. method="get") then you can use Javascript to build a "querystring" but that can be a long and drawn out process for someone just starting out with js. I would suggest you stick with POST and handle it on the backend by checking for ObjRs("none")=null (or something like that, its been a while since I used asp).

If you are dead set on using Javascript then you can find many good tuts on building querystrings with js on the web.

Good luck with it.

werD
02-03-2005, 10:28 PM
I kinda thought it would be a little easier on the backend I was told to use javascript from someone that hadn't seen any of the code yet Thanks a bunch For saving me the trouble:)


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

write to an html file dynamically?
FireFox doesn't recognize history.go(-1)
Changing e.keyCode (e.which)
Clearing a range created by element.createTextRange()
UPDATE: My mouse over pop up question
I am having problem with this script!!!
Creating Handlers
"Login ID" pass over to subsequent pages visited

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics