weightID and starID were the parameters of the function checkWeight. The quoted strings were in the call to checkWeight.
Dave S ----- Original Message ----- From: Dan Powderhill To: [email protected] Sent: Wednesday, August 03, 2005 12:21 AM Subject: RE: [ASP] Updating a CHECKBOX when a value is entered in a FORM I can't say I've tried passing getElementById an unquoted parameter. If it wasn't quoted then by the nature of Javascript it'd need to be a variable, constant or function name, whereas the ID in this case is a string attribute value. All the references I can find suggest that it takes a string as a parameter, and therefore needs to be quoted. http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getelementbyid.asp http://www.mozilla.org/docs/dom/domref/dom_doc_ref48.html Dan -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of David Smart Sent: 02 August 2005 14:07 To: [email protected] Subject: Re: [ASP] Updating a CHECKBOX when a value is entered in a FORM No you don't. Dave S ----- Original Message ----- From: Dan Powderhill To: [email protected] Sent: Tuesday, August 02, 2005 6:06 PM Subject: RE: [ASP] Updating a CHECKBOX when a value is entered in a FORM You need quotes around WeightID and StarID. Dan -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Madòrick Sent: 02 August 2005 00:45 To: [email protected] Subject: Re: [ASP] Updating a CHECKBOX when a value is entered in a FORM I really appreciate all of the help with this problem. I tried the code suggested, it still is not working. I'm not getting an error just not updating the checkbox. I haven't been able to find any documentation on the "document.getElementById command". Please see the attached code and tell me what might be wrong. I also thought the assignment in the "var" command might need a "==" but no luck. <SCRIPT language="JavaScript" type="text/JavaScript"> function checkWeight (WeightID, StarID) { var Weight = document.getElementById (WeightID); var Star = document.getElementById (StarID); Star.checked = True; } </SCRIPT> <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="Weight2" size="5" maxlength="3" onChange='checkWeight ("Weight2", "Star2")'> <INPUT type="checkbox" name="BirthCert" value="True"> <INPUT type="checkbox" name="Star" id="Star2" value="True"> </LABEL></TH> </TR> </TABLE> </FORM> Any and all help with this is greatly appreciated. I have some understanding of JAVA but not any real experience coding it. --- In [email protected], "David Smart" <[EMAIL PROTECTED]> wrote: > Pretty much. A couple of things ... > > Keep the names of the fields the same as their IDs. This will minimise confusion. Annoyingly, you need both, as the client-side script will use IDs, but ASP will use names. > > To set the checkmark in a checkbox, you set its checked property to true. I.e.: > > checkBox.checked = True; > > One last thing. If you're going to be writing the ASP code this week too, note that unchecked checkboxes are not visible to ASP, only checked ones. This is a pain in the proverbial, and makes for annoying code in ASP. > > Essentially, you have to check to see if the checkbox exists in the submitted form, and if it does, you know it's checked. In JScript, I have > > var checkboxChecked = String (Request.form ("Star2")) ! = "undefined"; > > VBScript will be similar, and a search with Google will find you examples, I'm sure. > > To be more flexible, I've defined a function to do the check, and an equivalent would be useful in VBScript too. My JScript function is: > > function checkboxChecked (name) > { > return String (Request.form (name)) != "undefined"; > } > > Dave S > > ----- Original Message ----- > From: Madòrick > To: [email protected] > Sent: Monday, August 01, 2005 1:20 AM > Subject: Re: [ASP] Updating a CHECKBOX when a value is entered in a FORM > > > Thanks for the quick Info, this is for a youth sports league and > they want a demo next weekend. This is the last page. Ok so I want > to paraphrase to be sure I understand... I want to see it work first > before I put conditions on the change...... > > First I should change my <INPUT> tag.... > From: > <INPUT name="Weight" type="text" id="Weight" size="5" maxlength="3"> > > To: > <INPUT name="Weight" type="text" id="Weight2" size="5" maxlength="3" > onChange='checkWeight ("Weight2", "Star2")'> > > AND > <INPUT type="checkbox" name="Star" value="True"> > To: > <INPUT type="checkbox" name="Star" id="Star2" value="True"> > > Then add somewhere at the beginnning: > <script language="JavaScript1.1"> > function checkWeight (WeightID, StarID) > { > > var textField = document.getElementById (textFieldID); > var checkBox = document.getElementById (checkBoxID); > > checkBox = True; > > } > > </script> > > > Thanks for the help in advance.... > > --- In [email protected], "David Smart" > <[EMAIL PROTECTED]> wrote: > > 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] > > > > > ----------------------------------------------------------------- ---- > 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=12hig8gsm/M=362131.6882499.7825260.1510227/D=groups/S=1705115381:TM/Y=YAHOO/EXP=1122947092/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 --------------------------------------------------------------------- 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=12hohnpnf/M=362131.6882499.7825260.1510227/D=groups/S=1705115381:TM/Y=YAHOO/EXP=1122995282/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 --------------------------------------------------------------------- Home : http://groups.yahoo.com/group/active-server-pages --------------------------------------------------------------------- Post : [email protected] Subscribe : [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] --------------------------------------------------------------------- SPONSORED LINKS Active server pages ------------------------------------------------------------------------------ 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=12h51mivc/M=362131.6882499.7825260.1510227/D=groups/S=1705115381:TM/Y=YAHOO/EXP=1123075273/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/
