JScript Help...Concatenation & FOR LOOP

Results 1 to 2 of 2

Thread: JScript Help...Concatenation & FOR LOOP

  1. #1
    Join Date
    Dec 1969

    Default JScript Help...Concatenation & FOR LOOP

    Good morning Programmers Unite<BR><BR>Just like to say thanks before we start…<BR><BR>I have the following code in Jscript and it’s triggered with an OnFocus event …<BR><BR>//Check box checked <BR>function Check(value) {<BR><BR>c = value <BR><BR>if(c == "Checkbox_Checked") {<BR><BR> bla, bla ,bla….<BR> }<BR><BR>if(c == "Checkbox_UnChecked") {<BR><BR>document.form1.Checkbox_M_1.checked = false;<BR>document.form1.Checkbox_M_2.checked = false;<BR>document.form1.Checkbox_M_3.checked = false;<BR>document.form1.Checkbox_M_4.checked = false;<BR>document.form1.Checkbox_M_5.checked = false;<BR>document.form1.Checkbox_M_6.checked = false;<BR>document.form1.Checkbox_M_7.checked = false;<BR>document.form1.Checkbox_M_8.checked = false;<BR>document.form1.Checkbox_M_9.checked = false;<BR>document.form1.Checkbox_M_10.checked = false;<BR>document.form1.Checkbox_M_11.checked = false;<BR>document.form1.Checkbox_M_12.checked = false;<BR>document.form1.Checkbox_M_13.checked = false;<BR>document.form1.Checkbox_M_14.checked = false;<BR>document.form1.Checkbox_M_15.checked = false;<BR>document.form1.Checkbox_M_16.checked = false;<BR>document.form1.Checkbox_M_17.checked = false;<BR><BR>}<BR> <BR>}<BR><BR>I would like to put the code above in a FOR LOOP to reduce it a bit<BR><BR>for (i = 0; i &#060; 18; i++)<BR><BR>{ <BR>(document.form1.Checkbox_M_+[i]).checked = false; <BR>}<BR><BR>My Question…Is it possible to concatenate a object name and how do I go about doing so.<BR><BR>I have done this a million times in VBScript, but I’m not sure on how this works in Jscript. <BR><BR>Thanks again<BR><BR>L<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Aint advanced...

    By the way, it may be better to use an onClick event and pass the checkbox object into the function, and use that to check if it&#039;s checked, but hey...<BR><BR><BR>function Check(value){<BR> if(value == "Checkbox_UnChecked"){<BR> for(var i=0; i&#060;18; i++){<BR> document.form1["Checkbox_M_" + i].checked = false;<BR> }<BR> }<BR>}<BR><BR>Craig.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts