[Javascript] Need Checkbox help.

Peter Brunone peter at brunone.com
Tue Aug 21 14:58:55 CDT 2001


Oh... *duh*... I just realized what I should have seen five posts ago.

    You're passing an undefined variable -- the value generated by
<%=rsDisplayAll("parent_id")%> -- into the function.  The only reason the
function doesn't balk is that the value is an integer.
    To make this work, you need to build the object reference to the parent
checkbox using the eval() function, like this:

function selectParent(cBox,pBox)
{
    if(cBox.checked == true) {
        var parentBox = eval("document.precert_request_form5." + pBox);
        parentBox.checked = true;
        }
    }

    I would also recommend appending a non-numeric character to the IDs as
part of the name so that the JS engine doesn't get confused and think that
you want to work with integer values, but that's up to you.

Cheers,

Peter

----- Original Message -----
From: "Quale, Michael" <QualeM at americanimaging.net>
To: <javascript at LaTech.edu>
Sent: Tuesday, August 21, 2001 2:19 PM
Subject: RE: [Javascript] Need Checkbox help.


| OK Here goes:
|
| As for the checkboxes being named the same, I do not see this as a problem
| because I'm using a unique item_id for each box.
|
| Here is an example of what I get:
|
| Parent:
|
| <input type=checkbox id="118" name="118" value="118">
|
| Child:
|
| <input type=checkbox id="119" name="119" value="119" LANGUAGE=javascript
| onclick="selectParent(this,118)">
|
| Do you think this could be a character problem?
|
| Numeric vs Char?
|
| Thanks for your help.
|
| Mike Q.
|
|
| -----Original Message-----
| From: Peter Brunone [mailto:peter at brunone.com]
| Sent: Tuesday, August 21, 2001 2:19 PM
| To: javascript at LaTech.edu
| Subject: Re: [Javascript] Need Checkbox help.
|
|
| Michael,
|
|     It would be helpful to see the output, i.e. what the ASP code is
| generating as the name of the checkbox.  This could very well be your
| problem.
|     Additionally, you might have more than one checkbox of the same name;
| this would create a similar problem.
|
| -Peter
|
| ----- Original Message -----
| From: "Quale, Michael" <QualeM at americanimaging.net>
| To: <javascript at LaTech.edu>
| Sent: Tuesday, August 21, 2001 1:35 PM
| Subject: [Javascript] Need Checkbox help.
|
|
| | I'm creating a dynamic list of check boxes based on the form selected.
| |
| | I have parent checkboxes which can have multiple child checkboxes.
| |
| | If a user selects a child I need to (onchange) check the parent
checkbox.
| |
| | I'm tried many combinations of the code below but keep getting
| | "document.precert_request_form5.pBox not an object" errors.
| |
| | **********
| | <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
| | <!--
| | function selectParent(cBox,pBox)
| | {
| | if(cBox.checked == true) {
| | document.precert_request_form5.pBox.checked = true;
| | }
| | }
| |
| | //-->
| | </SCRIPT>
| | *********
| |
| | 'Dynamically built parent checkbox
| | <input type=checkbox id="<%=rs("item_id")%>" name="<%=rs("item_id")%>"
| | value="<%=rs("item_id")%>">
| |
| | 'Dynamically built child checkbox
| | <input type=checkbox id="<%=rs("item_id")%>" name="<%=rs("item_id")%>"
| | value="<%=rs("item_id")%>" LANGUAGE=javascript
| | onclick="selectParent(this,<%=rsDisplayAll("parent_id")%>)">
| |
| | Any help is good help!
| |
| | Thanks,
| |
| | Mike Q.
|
| _______________________________________________
| Javascript mailing list
| Javascript at LaTech.edu
| http://www.LaTech.edu/mailman/listinfo/javascript
| _______________________________________________
| Javascript mailing list
| Javascript at LaTech.edu
| http://www.LaTech.edu/mailman/listinfo/javascript
|




More information about the Javascript mailing list