You have found onChange and that is probably what you want. Note, however,
that onChange will only trigger when you move away from the field. This may
not be aesthetically pleasing, as your cursor will be on another field
(possibly on another row) before the checkbox gets checked. Anyway ...
First thing. You will not be using ASP for this. This will be client-side
code, and you'll need to do it in JavaScript.
All you need to do is to put an onchange clause into your input field. E.g.
onchange='checkWeight ("InputBoxID", "CheckBoxID")'
Note the single quotes around the JavaScript statement and the double quotes
around the string parameters.
You are going to have to give your fields unique IDs on each row, so that you
can separate out the fields for the different people. This can be done with a
simple counter in your ASP.
You'll then need a JavaScript function to do the work. This will simply be
defined in a <script> area.
<script>
function checkWeight (textFieldID, checkBoxID)
{
var textField = document.getElementById (textFieldID);
var checkBox = document.getElementById (checkBoxID);
stuff
}
</script>
Hope this is a start. Sounds as though you're pretty much on the right track.
Dave S
----- Original Message -----
From: Madòrick
To: [email protected]
Sent: Sunday, July 31, 2005 10:04 PM
Subject: [ASP] Updating a CHECKBOX when a value is entered in a FORM
Please bare with me, I am a long time Mainframe programmer trying to
learn ASP and VBScript. I have two things I am looking for some
help with.
1) I want to display rows with information for people (ie. name,
date ect.) and have one field to be a TEXTBOX to enter information
into. This is to be flollowed on the same row with a CHECKBOX tha I
want to update based on what is entered in the TEXTBOX (see below),
if the weight is greater than a given weight the CHECKBOX should
become checked. This means two things 1. I need to verify the
entered information is only numbers and 2. I need to compare the
entered number to a given value. In reading on the <INPUT> tag I
see that the Method "onChange" is available, how do I use/trigger a
method from the <INPUT> tag?
2) Actually #1 might help with this question... When someone enters
data on the line and goes to the next line I would like to initiate
some code to update the database with that information.
My input lines are simular to this:
There can be several lines.
First Name & Last Name are Display only
Date & Weight must be entered (X = check box)
I have a weight limit available from the Database to compare the
entered weight to.
First Name Last Name Date Weight X
First Name Last Name Date Weight X
First Name Last Name Date Weight X
etc.
Here is one of the Forms I set up, this represents a single line:
<FORM name="Player2" method="post" action="EditTeam.asp">
<TABLE width="80%" border="0" cellpadding="0" cellspacing="0"
summary="Summary">
<TR>
<TH scope="row"><LABEL>
<INPUT name="FirstName" type="text" id="FirstName" size="17"
Maxlength="15">
<INPUT name="LastName" type="text" id="LastName" size="27"
maxlength="25">
<INPUT name="MI" type="text" size="3" maxlength="1">
<INPUT name="BirthDate" type="text" id="BirthDate" size="12"
maxlength="10">
<INPUT name="JerseyNumber" type="text" id="JerseyNumber" size="4"
maxlength="2">
<INPUT name="Weight" type="text" id="Weight" size="5" maxlength="3">
<INPUT type="checkbox" name="BirthCert"
value="True"> &n
bsp;
<INPUT type="checkbox" name="Star"
value="True">
<INPUT type="submit" name="Accept" value="Accept">
</LABEL></TH>
<TD> </TD>
</TR>
</TABLE>
</FORM>
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [email protected]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
------------------------------------------------------------------------------
YAHOO! GROUPS LINKS
a.. Visit your group "active-server-pages" on the web.
b.. To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
------------------------------------------------------------------------------
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hk9p068/M=362131.6882499.7825260.1510227/D=groups/S=1705115381:TM/Y=YAHOO/EXP=1122820843/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~->
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [email protected]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/active-server-pages/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/